如何为
Firebase
和 GitHub
工作流程指定文件夹名称。基本上我有一个 .github
文件夹,其中存储 .yml
文件,但我也有 frontend
文件夹,其中存储我的 React.js src 文件和其他需要的东西。
现在,当我推送更改时,我收到此错误:
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-03-29T10_09_41_940Z-debug-0.log
这是我的
.yml
文件:
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: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_REACTTASK_20C61 }}"
channelId: live
projectId: reacttask-20c61
workingdirectory: ./frontend
如何使我的
frontend
文件夹成为工作目录,因为现在看来不是
使用
entryPoint
选项
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_REACTTASK_20C61 }}"
channelId: live
projectId: reacttask-20c61
entryPoint: ./frontend
有关更多详细信息,请参阅文档
这是一个很老的问题,但这是我的解决方案,以防其他人最终来到这里。
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build FE
working-directory: ./frontend
run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DATAEDU_WEB }}
channelId: live
projectId: dataedu-web
entryPoint: ./frontend
就您而言,您需要
working-directory: ./frontend
来构建。您还需要 entryPoint: ./frontend
才能部署到 Firebase。