I'm using Firebase Cloud Functions for a project and I would like to automatically deploy them when I push in a specific branch on GitHub. Here is my current workflow :
name: Dev deploy
on:
workflow_dispatch:
push:
branches:
- develop
jobs:
deploy_functions:
name: Deploy Functions
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-16-${{ hashFiles('**/package-lock.json') }}
- name: Node install
run: |
cd functions
npm install
npm ci
- name: Create SA key
run: echo '${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT_DEV }}' > gcloud.json
- name: Create .firebaserc
run: ./.github/actions-scripts/build-firebaserc.sh > .firebaserc
env:
PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID_DEV }}
- name: Debug
run: |
cat .firebaserc
npx firebase-tools projects:list
env:
GOOGLE_APPLICATION_CREDENTIALS: gcloud.json
- name: Deploy Cloud Functions
run: npx firebase-tools deploy --only functions
env:
GOOGLE_APPLICATION_CREDENTIALS: gcloud.json
The Debug
step gives me this:
Project Display Name | Project ID | Project Number | Resource Location ID |
---|---|---|---|
My project name | *** (current) | *** | europe-west |
Therefore, my credentials have successfully access to my project. However, when I try to deploy in the next step I have the output:
=== Deploying to '***'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> lint
> eslint .
✔ functions: Finished running predeploy script.
Error: Failed to get Firebase project ***. Please make sure the project exists and your account has permission to access it.
Error: Process completed with exit code 2.
Any idea how to fix it?
- I cannot do
firebase login:reauth
on a CI. - Running
firebase use ${{ secrets.FIREBASE_PROJECT_ID_DEV }}
raises the same error.
Thank you for your help.