Skip to content

Load Library API Metadata #13

Load Library API Metadata

Load Library API Metadata #13

name: Load Library API Metadata
on:
workflow_dispatch:
workflow_call:
env:
PROJECT_ID: benefit-decision-toolkit-play
REGION: us-central1
WORKLOAD_IDENTITY_PROVIDER: projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github
jobs:
run-script:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
# use a specific service account for sync script
- name: Create GCP credentials file (for sync script)
run: |
echo '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' > bin/library/gcp-key.json
- name: Run sync
working-directory: bin/library
env:
GOOGLE_APPLICATION_CREDENTIALS: gcp-key.json
LIBRARY_API_BASE_URL: https://library-api-1034049717668.us-central1.run.app
run: |
./sync-metadata
- name: Cleanup credentials
run: rm bin/library/gcp-key.json
# Use a different service account with permissions to restart builder-api
- name: Authenticate to Google Cloud (for restarting builder-api)
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: cicd-build-deploy-api@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
project_id: ${{ env.PROJECT_ID }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Restart builder-api with updated library metadata
run: |
gcloud run services update builder-api \
--region ${{ env.REGION }} \
--update-env-vars LIBRARY_SYNC_TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)