Firebase 托管构建失败,因为 process.env.ci 设置为 true

Firebase hosting build fails because process.env.ci is set to true

我正在尝试将 create-react-app 部署到 firebase 托管。

我按照入门指南中的步骤进行操作,并为我设置了 github 操作工作流程。 看起来是这样的:

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - master
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm install && npm run build
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_xxxxx }}'
          channelId: live
          projectId: master
        env:
          FIREBASE_CLI_PREVIEWS: hostingchannels
          CI: false

但是;当我推送一个新的提交时,构建失败是因为 Treating warnings as errors because process.env.CI = true.

如您所见,我尝试通过添加 CI: false 来解决此问题,但 CI 仍设置为 true。我怎样才能解决这个问题?为什么我尝试解决这个问题不起作用?

解决方法是将 CI: false 移动到 build_and_deploy 步骤上方:

env:
  CI: false

jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm install && npm run build
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_xxxxx }}'
          channelId: live
          projectId: xxxxxx
        env:
          FIREBASE_CLI_PREVIEWS: hostingchannels

为什么有 2 个 env?不知道。但它有效。