|
| 1 | +name: Build and Deploy to Firebase Hosting |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +env: |
| 9 | + PROJECT_ID: 'benefit-decision-toolkit-play' |
| 10 | + WORKLOAD_IDENTITY_PROVIDER: 'projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github' |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-and-deploy: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + # Add these permissions for Workload Identity Federation |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + id-token: write |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + # Configure Workload Identity Federation and generate an access token. |
| 26 | + # |
| 27 | + # See https://github.com/google-github-actions/auth for more options, |
| 28 | + # including authenticating via a JSON credentials file. |
| 29 | + - id: 'auth' |
| 30 | + name: 'Authenticate to Google Cloud' |
| 31 | + uses: 'google-github-actions/auth@v2' |
| 32 | + with: |
| 33 | + workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}' |
| 34 | + service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com |
| 35 | + project_id: ${{ env.PROJECT_ID }} |
| 36 | + |
| 37 | + - name: Setup Node.js |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: '18' |
| 41 | + |
| 42 | + - name: Cache node modules |
| 43 | + uses: actions/cache@v3 |
| 44 | + with: |
| 45 | + path: screener-frontend/node_modules |
| 46 | + key: ${{ runner.os }}-node-${{ hashFiles('screener-frontend/package-lock.json') }} |
| 47 | + restore-keys: | |
| 48 | + ${{ runner.os }}-node- |
| 49 | + cache: 'npm' |
| 50 | + cache-dependency-path: 'screener-frontend/package-lock.json' |
| 51 | + |
| 52 | + - name: Install dependencies |
| 53 | + working-directory: screener-frontend |
| 54 | + run: npm ci |
| 55 | + |
| 56 | + - name: Build application |
| 57 | + working-directory: screener-frontend |
| 58 | + run: npm run build |
| 59 | + |
| 60 | + - name: Install Firebase CLI |
| 61 | + run: npm install -g firebase-tools |
| 62 | + |
| 63 | + - name: Deploy to Firebase Hosting |
| 64 | + run: firebase deploy --only hosting:screener-frontend |
0 commit comments