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

Viewed 638

I am trying to deploy a create-react-app to firebase hosting.

I followed the step in the Get Started guide, and got a github actions workflow set up for me. It looks like so:

# 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

However; when I push a new commit, the build fails because of Treating warnings as errors because process.env.CI = true.

As you can see, I tried to fix this with adding CI: false, but CI is still being set to true. How can I fix this? And why is my attempt at solving this not working?

1 Answers

The fix was to move CI: false above the build_and_deploy step:

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

Why are there 2 env's? No idea. But it works.

Related