Skip to content

Commit 4883201

Browse files
authored
Merge pull request #300 from CodeForPhilly/automate-library-api-release-steps
Automate library sync when new version is pushed
2 parents c936a29 + 35d5e96 commit 4883201

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ jobs:
122122
echo "Service URL: ${{ steps.deploy.outputs.url }}"
123123
echo "Version: v${{ steps.extract_version.outputs.version }}"
124124
echo "Revision: ${{ env.API_NAME }}-v${{ steps.extract_version.outputs.revision_version }}"
125+
126+
sync-metadata:
127+
needs: deploy
128+
uses: ./.github/workflows/load-library-metadata.yml
129+
secrets: inherit

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ 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+
WORKLOAD_IDENTITY_PROVIDER: projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github
511

612
jobs:
713
run-script:
814
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
id-token: write
918

1019
steps:
1120
- name: Checkout repo
@@ -16,7 +25,8 @@ jobs:
1625
with:
1726
python-version: "3.11"
1827

19-
- name: Create GCP credentials file
28+
# use a specific service account for sync script
29+
- name: Create GCP credentials file (for sync script)
2030
run: |
2131
echo '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' > bin/library/gcp-key.json
2232
@@ -30,3 +40,20 @@ jobs:
3040
3141
- name: Cleanup credentials
3242
run: rm bin/library/gcp-key.json
43+
44+
# Use a different service account with permissions to restart builder-api
45+
- name: Authenticate to Google Cloud (for restarting builder-api)
46+
uses: google-github-actions/auth@v2
47+
with:
48+
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
49+
service_account: cicd-build-deploy-api@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
50+
project_id: ${{ env.PROJECT_ID }}
51+
52+
- name: Set up Cloud SDK
53+
uses: google-github-actions/setup-gcloud@v2
54+
55+
- name: Restart builder-api with updated library metadata
56+
run: |
57+
gcloud run services update builder-api \
58+
--region ${{ env.REGION }} \
59+
--update-env-vars LIBRARY_SYNC_TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)

0 commit comments

Comments
 (0)