为 Firebase 托管设置 Github 操作时找不到 package.json 文件

rya*_*tan 3 firebase firebase-hosting github-actions

当初始化 firebase 托管的 github 操作时,我指定了以下内容:

设置工作流程以在每次部署之前运行构建脚本?是 每次部署之前应运行什么脚本?纱线运行构建。

这个工作流程给了我错误

Run yarn run build
yarn run v1.22.10
error Couldn't find a package.json file in "/home/runner/work/SpaceBar/SpaceBar"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)

我的项目目录中有一个 package.json 文件。为什么说找不到呢?

firebase-hosting-merge.yml 位于名为 spacebar 的目录中,其中包含另一个名为 spacebar 的目录,其中包含 package.json 文件。是否有办法 cd 到该文件的子目录中

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - main
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: yarn run build
      - uses: FirebaseExtended/action-hosting-deploy@v0
Run Code Online (Sandbox Code Playgroud)

Gui*_*urd 7

由于该actions/checkout操作使您可以访问存储库文件和目录,因此您可以在执行命令之前进入文件所在的cd目录。否则,它只会在存储库根目录中查找它。package.jsonyarn

示例(第二步)

run: |
   cd spacebar/spacebar
   yarn run build
Run Code Online (Sandbox Code Playgroud)