使用 Github 操作的 Teams-cli 找不到 package.json

Teams-cli using Github actions fails to find package.json

使用以下脚本发布 Microsoft 团队应用程序:

steps:
  # Setup environment.
  - uses: actions/setup-node@v2
    with:
      node-version: '14'
  - run: npm install

  - name: Checkout the code
    uses: actions/checkout@v2

  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: validate

  # Publish the Teams App.
  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: publish

我在验证和发布操作中收到以下查找包错误:

UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/node_modules/undefined/package.json'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at getVersionString (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:61:28)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:87:18
    at Generator.next (<anonymous>)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:30:71
    at new Promise (<anonymous>)
    at __awaiter (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:26:12)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:68:8
    at Object.<anonymous> (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:89:4)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1721) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1721) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

运行 通过控制台本地命令或使用 Visual Code Teams 工具包都 运行 成功,没有问题,我看不出我在这里可能遗漏了什么。

将脚本更新为以下内容以正确安装所需的包:

steps:
  # Setup environment.
  - uses: actions/setup-node@v2
    with:
      node-version: '14'
  - uses: pnpm/action-setup@v2.0.1
    with:
        version: 6.12.1
  - name: Checkout
    uses: actions/checkout@v2.3.1
    with:
      persist-credentials: false
  - name: Install and Build 
    run: | # Install npm packages
      pnpm install

  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: validate

  # Publish the Teams App.
  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: publish

@RichardMc 你自己解决了吗?

我从第一个版本中看到的一个问题是,你应该在 Checkout 之后 运行 npm install,而不是在它之前。

其实你不用那么麻烦单独使用action,自己写workflow文件。 存在 CI/CD 对 Teams 应用程序开发的支持,它通过脚本涵盖 GitHub、Azure DevOps、Jenkins 和其他平台的平台。 您只需要为 GitHub 复制预定义的 yml 文件并进行自定义以满足您自己的要求。

详情请参考https://aka.ms/teamsfx-cicd-insider-guide