Skip to content

Commit c09db1b

Browse files
committed
ci: add optional Cloud Run deploy job gated on repo variables
The deploy job is skipped unless GCP_PROJECT_ID is set as a repository variable, so it is a no-op for the public repo and forks. A downstream mirror that sets the required variables (GCP_PROJECT_ID, GCP_WIF_PROVIDER, CLOUD_RUN_SERVICE, CLOUD_RUN_REGION, BASE_URI, CLOUD_RUN_VPC_CONNECTOR, CLOUD_RUN_SERVICE_ACCOUNT) gets automatic deploys on push to main without carrying a workflow diff. Sets --memory=1Gi since the default 512Mi was running at 95-98% utilization under typical load.
1 parent 4555e80 commit c09db1b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,40 @@ jobs:
2424
- run: npm test
2525

2626
- run: npm run lint
27+
28+
deploy:
29+
runs-on: ubuntu-latest
30+
needs: build
31+
if: github.ref == 'refs/heads/main' && vars.GCP_PROJECT_ID != ''
32+
permissions:
33+
contents: read
34+
id-token: write
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: google-github-actions/auth@v2
40+
with:
41+
project_id: ${{ vars.GCP_PROJECT_ID }}
42+
workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }}
43+
44+
- id: deploy
45+
uses: google-github-actions/deploy-cloudrun@v2
46+
with:
47+
service: ${{ vars.CLOUD_RUN_SERVICE }}
48+
region: ${{ vars.CLOUD_RUN_REGION }}
49+
source: .
50+
env_vars: |-
51+
BASE_URI=${{ vars.BASE_URI }}
52+
NODE_ENV=production
53+
REDIS_TLS=0
54+
secrets: |-
55+
REDIS_URL=REDIS_URL:latest
56+
flags: |-
57+
--vpc-connector=${{ vars.CLOUD_RUN_VPC_CONNECTOR }}
58+
--service-account=${{ vars.CLOUD_RUN_SERVICE_ACCOUNT }}
59+
--allow-unauthenticated
60+
--min-instances=1
61+
--max-instances=20
62+
--concurrency=250
63+
--memory=1Gi

0 commit comments

Comments
 (0)