Skip to content

Commit 6c6cb09

Browse files
committed
ci: pass OPENAI_API_KEY and FLASK_SECRET to Cloud Run
1 parent ba628de commit 6c6cb09

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

.github/workflows/deploy.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
1-
# GitHub Actions workflow:
2-
# Builds the repo’s Docker image with Cloud Build
3-
# and deploys it as a new revision of the existing
4-
# Cloud Run service “wasteassistant”.
1+
# GitHub Actions workflow
2+
# ──────────────────────────────────────────────────────────────────────────
3+
# • Builds the application with Cloud Build (Buildpacks, from source).
4+
# • Deploys the resulting container as a new revision of the existing
5+
# Cloud Run service “wasteassistant”.
6+
# • Passes runtime secrets (OpenAI key + Flask secret) via env-vars.
7+
# • Triggers on every push to main and via the manual “Run workflow” button.
8+
# ──────────────────────────────────────────────────────────────────────────
59

610
name: Build & Deploy to Cloud Run
711

8-
# ─── Triggers ───────────────────────────────────────────────────────────
12+
# ─── Triggers ───────────────────────────────────────────────────────────
913
on:
10-
push: # run on every push to main
14+
push: # automatic deploy on each push to main
1115
branches: ["main"]
12-
workflow_dispatch: # manual “Run workflow” button
16+
workflow_dispatch: # enable manual runs from the UI
1317

14-
# ─── Single job ────────────────────────────────────────────────────────
18+
# ─── Job definition ──────────────────────────────────────────────────────
1519
jobs:
1620
build-and-deploy:
17-
runs-on: ubuntu-latest # use the hosted GitHub runner
21+
runs-on: ubuntu-latest # GitHub-hosted runner
1822

1923
steps:
20-
# 1️⃣ Check out the repository at this commit
24+
# 1️⃣ Check out repository contents at the current commit
2125
- name: Checkout source
2226
uses: actions/checkout@v4
2327

24-
# 2️⃣ Authenticate the runner to GCP using the service-account key
25-
# stored in the repository secret GCP_SA_KEY.
28+
# 2️⃣ Authenticate to Google Cloud using a service-account key
29+
# stored in the secret GCP_SA_KEY (JSON key with the required roles).
2630
- name: Authenticate to Google Cloud
2731
uses: google-github-actions/auth@v1
2832
with:
2933
credentials_json: ${{ secrets.GCP_SA_KEY }}
3034

31-
# 3️⃣ Build the image from the repo root and deploy it
32-
# Cloud Build is invoked under the hood by “source: .”.
33-
# The env_vars section passes runtime secrets to the container.
35+
# 3️⃣ Build from source and deploy in a single command.
36+
# The Buildpacks flow (source: .) invokes Cloud Build automatically,
37+
# stores the image in Artifact Registry and creates a new revision.
38+
# env_vars injects the runtime secrets into the container.
3439
- name: Deploy to Cloud Run
3540
uses: google-github-actions/deploy-cloudrun@v2
3641
with:
37-
service: wasteassistant # existing Cloud Run service
38-
source: . # buildpacks build from repo root
42+
service: wasteassistant # existing Cloud Run service
43+
source: . # buildpacks build from repo root
3944
project_id: ${{ secrets.GCP_PROJECT_ID }}
40-
region: ${{ secrets.GCP_REGION }}
41-
env_vars: |
45+
region: ${{ secrets.GCP_REGION }}
46+
env_vars: | # runtime secrets
4247
api_key=${{ secrets.OPENAI_API_KEY }}
4348
secret_key=${{ secrets.FLASK_SECRET }}
44-
flags: --allow-unauthenticated # keep the public URL accessible
49+
flags: --allow-unauthenticated # keep the public URL open

0 commit comments

Comments
 (0)