Skip to content

Commit 8b7afc6

Browse files
committed
Automate library sync when new version is pushed
git push origin library-api-vX.X.X ↓ deploy — builds library-api, pushes Docker image, deploys to Cloud Run — waits until new revision is healthy ↓ sync-metadata — calls load-library-metadata.yml (workflow_call) ├─ sync — fetches OpenAPI spec, uploads check metadata to Firebase Storage/Firestore └─ restart — redeploys builder-api:latest to Cloud Run (no rebuild, ~30-60s) — new revision starts, @PostConstruct reads updated metadata Manual trigger (workflow_dispatch) also runs both sync + restart automatically.
1 parent a0fe412 commit 8b7afc6

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/deploy-library-api.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,8 @@ jobs:
129129
echo "Service URL: ${{ steps.deploy.outputs.url }}"
130130
echo "Version: v${{ steps.extract_version.outputs.version }}"
131131
echo "Revision: ${{ env.API_NAME }}-v${{ steps.extract_version.outputs.revision_version }}"
132+
133+
sync-metadata:
134+
needs: deploy
135+
uses: ./.github/workflows/load-library-metadata.yml
136+
secrets: inherit

.github/workflows/load-library-metadata.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@ name: Load Library API Metadata
22

33
on:
44
workflow_dispatch:
5+
workflow_call:
6+
7+
env:
8+
PROJECT_ID: benefit-decision-toolkit-play
9+
REGION: us-central1
10+
SERVICE: benefit-decision-toolkit-play
11+
WORKLOAD_IDENTITY_PROVIDER: projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github
512

613
jobs:
714
run-script:
815
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write
919

1020
steps:
1121
- name: Checkout repo
@@ -30,3 +40,19 @@ jobs:
3040
3141
- name: Cleanup credentials
3242
run: rm bin/library/gcp-key.json
43+
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@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
49+
project_id: ${{ env.PROJECT_ID }}
50+
51+
- name: Set up Cloud SDK
52+
uses: google-github-actions/setup-gcloud@v2
53+
54+
- name: Restart builder-api with updated library metadata
55+
run: |
56+
gcloud run deploy builder-api \
57+
--image us-central1-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/builder-api:latest \
58+
--region ${{ env.REGION }}

0 commit comments

Comments
 (0)