Skip to content
Latchkey

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-interactive

Gotchas

  • The account needs roles/cloudfunctions.developer and roles/iam.serviceAccountUser.
  • Pass --non-interactive so the CLI never blocks waiting for a prompt in CI.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →