Skip to content

Commit 2e815db

Browse files
committed
actions: add builder-frontend workflow
1 parent 1c95452 commit 2e815db

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses devbox for dependency management and builds/deploys the builder frontend
2+
# to Firebase Hosting when a commit is pushed to the "main" branch.
3+
4+
name: 'Build and Deploy Builder Frontend to Firebase Hosting'
5+
6+
on:
7+
push:
8+
branches:
9+
- 157-offline-dev
10+
paths:
11+
- 'builder-frontend/**'
12+
- 'devbox.json'
13+
- 'devbox.lock'
14+
15+
env:
16+
PROJECT_ID: 'benefit-decision-toolkit-play'
17+
WORKLOAD_IDENTITY_PROVIDER: 'projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github'
18+
19+
jobs:
20+
build-and-deploy:
21+
runs-on: ubuntu-latest
22+
23+
# Add these permissions for Workload Identity Federation
24+
permissions:
25+
contents: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
# Devbox needs a .env file to exist, even if it's empty
33+
- name: 'Create .env file'
34+
run: touch .env
35+
36+
# Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
37+
- name: 'Install devbox'
38+
uses: 'jetify-com/[email protected]'
39+
with:
40+
enable-cache: true
41+
42+
# Configure Workload Identity Federation and generate an access token
43+
- id: 'auth'
44+
name: 'Authenticate to Google Cloud'
45+
uses: 'google-github-actions/auth@v2'
46+
with:
47+
workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}'
48+
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
49+
project_id: ${{ env.PROJECT_ID }}
50+
51+
- name: Cache node modules
52+
uses: actions/cache@v4
53+
with:
54+
path: builder-frontend/node_modules
55+
key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }}
56+
restore-keys: |
57+
${{ runner.os }}-node-
58+
59+
- name: Install dependencies
60+
working-directory: builder-frontend
61+
run: devbox run -- npm ci
62+
63+
- name: Build application
64+
working-directory: builder-frontend
65+
run: devbox run -- npm run build
66+
env:
67+
VITE_API_URL: ${{ secrets.VITE_API_URL}}
68+
VITE_SCREENER_BASE_URL: ${{ secrets.VITE_SCREENER_BASE_URL}}
69+
VITE_API_KEY: ${{ secrets.VITE_API_KEY}}
70+
VITE_AUTH_DOMAIN: ${{ secrets.VITE_AUTH_DOMAIN}}
71+
VITE_PROJECT_ID: ${{ secrets.VITE_PROJECT_ID}}
72+
VITE_STORAGE_BUCKET: ${{ secrets.VITE_STORAGE_BUCKET}}
73+
VITE_MESSAGING_SENDER_ID: ${{ secrets.VITE_MESSAGING_SENDER_ID}}
74+
VITE_APP_ID: ${{ secrets.VITE_APP_ID}}
75+
VITE_MEASUREMENT_ID: ${{ secrets.VITE_MEASUREMENT_ID}}
76+
77+
- name: Deploy to Firebase Hosting
78+
run: devbox run -- firebase deploy --only hosting:builder-frontend

0 commit comments

Comments
 (0)