How to Deploy Firebase Functions With GitHub Actions
firebase deploy --only functions ships your functions, authenticating from CI with a service-account credential.
Install firebase-tools, point GOOGLE_APPLICATION_CREDENTIALS at a service-account file (or use WIF), then firebase deploy --only functions --project <id>.
Steps
- Authenticate via WIF (or a service-account credential).
- Install dependencies in the functions directory.
- Run
firebase deploy --only functions.
Workflow
.github/workflows/deploy.yml
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ vars.WIF_PROVIDER }}
service_account: ${{ vars.DEPLOY_SA }}
- run: npm --prefix functions ci
- run: npx firebase-tools deploy --only functions --project my-firebase-project --non-interactiveGotchas
- The account needs
roles/cloudfunctions.developerandroles/iam.serviceAccountUser. - Pass
--non-interactiveso the CLI never blocks waiting for a prompt in CI.
Related guides
How to Deploy a Firebase Hosting Site With GitHub ActionsDeploy a site to Firebase Hosting from GitHub Actions using the FirebaseExtended/action-hosting-deploy action…
How to Deploy a 2nd Gen Cloud Function With GitHub ActionsDeploy a 2nd gen Cloud Function from GitHub Actions with the deploy-cloud-functions action, setting runtime,…