fix: debug github workflow use wfi instead of firebase token #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy NestJS API to Firebase | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
checks: write | |
contents: write | |
deployments: write | |
id-token: write # This is required for requesting the JWT | |
issues: write | |
packages: write | |
pages: write | |
pull-requests: write | |
repository-projects: write | |
security-events: write | |
statuses: write | |
steps: | |
- name: Checkout actions-oidc-debugger | |
uses: actions/checkout@v4 | |
with: | |
repository: github/actions-oidc-debugger | |
ref: main | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./.github/actions/actions-oidc-debugger | |
- name: Debug OIDC Claims | |
uses: ./.github/actions/actions-oidc-debugger | |
with: | |
audience: 'projects/970886652672/locations/global/workloadIdentityPools/dev-ci-pool/providers/my-repo-oidc' | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Set correct firebase project based on git branch. | |
run: echo "FIREBASE_PROJECT=$(if [ ${{ github.ref }} == 'refs/heads/main' ]; then echo 'prod'; else echo 'dev'; fi)" >> $GITHUB_ENV | |
- name: Set correct GCP project | |
run: echo "GCP_PROJECT_FOR_BRANCH=$(if [ ${{ github.ref }} == 'refs/heads/main' ]; then echo 'weatherkids'; else echo 'weatherkids-dev'; fi)" >> $GITHUB_ENV | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: ${{ env.GCP_PROJECT_FOR_BRANCH }} | |
workload_identity_provider: 'projects/970886652672/locations/global/workloadIdentityPools/dev-ci-pool/providers/my-repo-oidc' | |
# service_account: '[email protected]' | |
- name: Install dependencies. | |
run: npm ci | |
- name: Extract GCP Service Account Credentials | |
run: | | |
echo "SERVICE_ACCOUNT_KEY=$(cat "${{ steps.auth.outputs.credentials_file_path }}" | tr -d '\n')" >> $GITHUB_ENV | |
- name: Deploy to firebase cloud functions. | |
uses: w9jds/[email protected] | |
with: | |
args: deploy --only functions --project ${{ env.FIREBASE_PROJECT }} | |
env: | |
MOBILE_CLIENT_ID: ${{ secrets.MOBILE_CLIENT_ID }} | |
WEATHERCOM_CLIENT_ID: ${{ secrets.WEATHERCOM_CLIENT_ID }} | |
GCP_SA_KEY: ${{ env.SERVICE_ACCOUNT_KEY }} |