Skip to content

Commit cdb3ddb

Browse files
committed
fix: construct Cloud Run SA email inline to use PROJECT_ID, clarify VITE_API_BASE_URL
GitHub Actions does not interpolate ${{ env.X }} inside the top-level env: block, so the full SA email could not reference PROJECT_ID there. Replaced CLOUD_RUN_SA with CLOUD_RUN_SA_NAME and build the email inline in the flags blocks where expression context is available. Added a comment explaining VITE_API_BASE_URL=/api — it is the nginx location prefix, not a full URL, because the browser calls the frontend's own origin and nginx proxies /api/* to the internal backend. https://claude.ai/code/session_01SRRzCWrpwgMpdYFurMVn7m
1 parent 27bb9b5 commit cdb3ddb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

.github/workflows/google-cloudrun-docker.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ env:
1818
BACKEND_SERVICE: 'querypal-backend'
1919
FRONTEND_SERVICE: 'querypal-frontend'
2020
WORKLOAD_IDENTITY_PROVIDER: 'projects/874216619692/locations/global/workloadIdentityPools/github/providers/querypal'
21-
# Cloud Run service account created by Terraform (terraform/iam.tf).
22-
CLOUD_RUN_SA: 'querypal-cloudrun-sa@gen-lang-client-0698668474.iam.gserviceaccount.com'
23-
# VPC connector created by Terraform (terraform/network.tf).
21+
# Short name of the Cloud Run SA and VPC connector created by Terraform.
22+
# The full SA email is constructed inline in flags using ${{ env.PROJECT_ID }}
23+
# because GitHub Actions does not interpolate env vars inside the env: block.
24+
CLOUD_RUN_SA_NAME: 'querypal-cloudrun-sa'
2425
VPC_CONNECTOR: 'querypal-vpc-connector'
2526

2627
jobs:
@@ -81,7 +82,7 @@ jobs:
8182
DB_PASS=querypal-db-pass:latest
8283
flags: |
8384
--port=8000
84-
--service-account=${{ env.CLOUD_RUN_SA }}
85+
--service-account=${{ env.CLOUD_RUN_SA_NAME }}@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
8586
--add-cloudsql-instances=${{ env.PROJECT_ID }}:${{ env.REGION }}:querypal-db
8687
--vpc-connector=${{ env.VPC_CONNECTOR }}
8788
--vpc-egress=private-ranges-only
@@ -94,6 +95,9 @@ jobs:
9495
run: |-
9596
cd frontend
9697
DOCKER_TAG="gcr.io/${{ env.PROJECT_ID }}/${{ env.FRONTEND_SERVICE }}:${{ github.sha }}"
98+
# VITE_API_BASE_URL=/api tells the React app to send all API calls to
99+
# the /api/* path on its own origin instead of a full backend URL.
100+
# Nginx then proxies those requests to the internal backend service.
97101
docker build --tag "${DOCKER_TAG}" --platform linux/amd64 \
98102
--build-arg VITE_API_BASE_URL=/api \
99103
--build-arg VITE_AZURE_REDIRECT_URI=https://querypal.virtonomy.io \
@@ -113,7 +117,7 @@ jobs:
113117
BACKEND_URL=${{ steps.deploy-backend.outputs.url }}
114118
flags: |
115119
--port=4000
116-
--service-account=${{ env.CLOUD_RUN_SA }}
120+
--service-account=${{ env.CLOUD_RUN_SA_NAME }}@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
117121
--vpc-connector=${{ env.VPC_CONNECTOR }}
118122
--vpc-egress=all-traffic
119123
--ingress=all

0 commit comments

Comments
 (0)