|
| 1 | +name: Run app services |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ main, master ] |
| 5 | + pull_request: |
| 6 | + branches: [ main, master ] |
| 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 | + run-services: |
| 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 | + # Devbox needs a .env file to exist, even if it's empty |
| 26 | + - name: 'Create .env file' |
| 27 | + run: touch .env |
| 28 | + |
| 29 | + # Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK |
| 30 | + - name: 'Install devbox' |
| 31 | + uses: 'jetify-com/[email protected]' |
| 32 | + with: |
| 33 | + enable-cache: true |
| 34 | + |
| 35 | + # Configure Workload Identity Federation and generate an access token |
| 36 | + - id: 'auth' |
| 37 | + name: 'Authenticate to Google Cloud' |
| 38 | + uses: 'google-github-actions/auth@v2' |
| 39 | + with: |
| 40 | + workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}' |
| 41 | + service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com |
| 42 | + project_id: ${{ env.PROJECT_ID }} |
| 43 | + |
| 44 | + - name: Cache node modules |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: builder-frontend/node_modules |
| 48 | + key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-node- |
| 51 | +
|
| 52 | + - name: Install dependencies |
| 53 | + working-directory: builder-frontend |
| 54 | + run: devbox run install-builder-frontend-ci |
| 55 | + |
| 56 | + - name: Run all services |
| 57 | + run: devbox services up -b |
| 58 | + continue-on-error: true |
| 59 | + |
| 60 | + # Insert additional steps here to interact with the running services, e.g., run tests |
| 61 | + |
| 62 | + - name: Stop all services |
| 63 | + run: devbox services stop |
| 64 | + continue-on-error: true |
0 commit comments