- Install
firebase-toolspackage (you can choose the package manager and the version to use) - Authenticate with service account key (recommanded) or firebase token
- Use specific project
- Launch the firebase command you want
⚠️ This action installfirebase-toolsnpm package, so you have to setup node before using it.
# ...jobs:
buildAndDeploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3# You need to setup node before using the action
- uses: actions/setup-node@v3with:
node-version: 16.xcache: npm# Add any steps. For example:# - run: npm ci && npm build
- uses: pchmn/firebase-cli-github-action@mainwith:
serviceAccountKey: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}projectId: your-projectIdargs: deploy --only functions# or:# args: deploy --only hosting# args: deploy --only firestore:rules| Name | Note | Description |
|---|---|---|
packager | (default to npm) | The package manager to use to install the CLI. See examples |
version | (default to latest) | The firebase-tools version to install |
serviceAccountKey | (required if token not set) | The service account key (JSON format) to use to authenticate with. See instructions |
token | (required if serviceAccountKey not set) | The firebase token to use to authenticate with. |
projectId | The project to use | |
args | Additional arguments to pass to the CLI. Example: deploy --only functions |
yarn:
# ...jobs:
jobName:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3with:
node-version: 16.xcache: yarn# ...
- uses: pchmn/firebase-cli-github-action@mainwith:
packager: yarn# other optionspnpm:
# ...jobs:
jobName:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2with:
version: 7.x
- uses: actions/setup-node@v3with:
node-version: 16.xcache: pnpm# ...
- uses: pchmn/firebase-cli-github-action@mainwith:
packager: pnpm# other optionsYou don't have to use args option, and you can launch firebase command in other steps after setting up the CLI.
# ...jobs:
deploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3with:
node-version: 16.xcache: npm# ...
- uses: pchmn/firebase-cli-github-action@mainwith:
# options# firebase command is now accessible
- run: firebase deploy --only functions1. Get a service account for your project (you can create one on GCP Service Accounts page) with any of these roles according to your needs:
Service Account User: required for CLI deploysCloud Functions Admin: required to deploy functionsCloud Scheduler Admin: required to deploy schedulded functionsFirebase Rules Admin: required to deploy Firestore/Firebase rulesCloud Datastore Index Admin: required to deploy Firestore indexesFirebase Hosting Admin: required to deploy hostingFirebase Authentication Admin: required to add preview URLs to Auth authorized domains
- Create and download your service account JSON key (see here)
- Add the content of JSON file as a secret in your repository (example:
FIREBASE_SERVICE_ACCOUNT_KEY) and use it asserviceAccountKeyoption:
- uses: pchmn/firebase-cli-github-action@mainwith:
serviceAccountKey: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
⚠️ This authentication method is deprecated, and is not recommanded. You should use a service account key instead
Run firebase login:ci in your terminal to get a token. Then add it as a secret in your repository (example: FIREBASE_TOKEN) and use it as token option:
- uses: pchmn/firebase-cli-github-action@mainwith:
token: ${{ secrets.FIREBASE_TOKEN }}This project is released under the MIT License.