Skip to content

Commit 1d17e7b

Browse files
committed
ci: switch cloud run env sync to oidc
1 parent 6ec36b0 commit 1d17e7b

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/sync-cloud-run-env.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ on:
44
push:
55
branches: [ main ]
66

7+
env:
8+
GCP_PROJECT_ID: interactivebrokersquant
9+
GCP_WORKLOAD_IDENTITY_PROVIDER: projects/303168642265/locations/global/workloadIdentityPools/github-actions/providers/github-main
10+
GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT: ibkr-platform-build@interactivebrokersquant.iam.gserviceaccount.com
11+
712
jobs:
813
sync-cloud-run-env:
914
name: Sync Cloud Run Env
1015
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write
1119
env:
1220
ENABLE_GITHUB_ENV_SYNC: ${{ vars.ENABLE_GITHUB_ENV_SYNC }}
1321
CLOUD_RUN_REGION: ${{ vars.CLOUD_RUN_REGION }}
@@ -20,7 +28,6 @@ jobs:
2028
IB_GATEWAY_IP_MODE: ${{ vars.IB_GATEWAY_IP_MODE }}
2129
GLOBAL_TELEGRAM_CHAT_ID: ${{ vars.GLOBAL_TELEGRAM_CHAT_ID }}
2230
NOTIFY_LANG: ${{ vars.NOTIFY_LANG }}
23-
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
2431
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
2532
steps:
2633
- name: Check whether env sync is configured
@@ -42,7 +49,6 @@ jobs:
4249
IB_ACCOUNT_GROUP_CONFIG_SECRET_NAME
4350
GLOBAL_TELEGRAM_CHAT_ID
4451
NOTIFY_LANG
45-
GCP_SA_KEY
4652
)
4753
4854
missing_vars=()
@@ -70,13 +76,14 @@ jobs:
7076
if: steps.config.outputs.enabled == 'true'
7177
uses: google-github-actions/auth@v3
7278
with:
73-
credentials_json: ${{ env.GCP_SA_KEY }}
79+
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
80+
service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}
7481

7582
- name: Set up gcloud
7683
if: steps.config.outputs.enabled == 'true'
7784
uses: google-github-actions/setup-gcloud@v3
7885
with:
79-
project_id: ${{ steps.auth.outputs.project_id }}
86+
project_id: ${{ env.GCP_PROJECT_ID }}
8087
version: ">= 416.0.0"
8188

8289
- name: Sync Cloud Run environment

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ Recommended setup:
201201
- `GLOBAL_TELEGRAM_CHAT_ID`
202202
- `NOTIFY_LANG`
203203
- **Repository Secrets**
204-
- `GCP_SA_KEY`
205204
- `TELEGRAM_TOKEN` (fallback only when `TELEGRAM_TOKEN_SECRET_NAME` is not set)
206205
- **Optional transition Variables**
207206
- `IB_GATEWAY_ZONE`
@@ -214,9 +213,9 @@ For now, `STRATEGY_PROFILE` still only supports one strategy profile. The curren
214213
Important:
215214

216215
- The workflow only becomes strict when `ENABLE_GITHUB_ENV_SYNC=true`. If this variable is unset, the sync job is skipped.
217-
- Here "shared config" still only means the **IBKR pair** (`InteractiveBrokersPlatform` + `IBKRGatewayManager`). `GCP_SA_KEY`, `TELEGRAM_TOKEN`, and `TELEGRAM_TOKEN_SECRET_NAME` remain repository-specific.
216+
- Here "shared config" still only means the **IBKR pair** (`InteractiveBrokersPlatform` + `IBKRGatewayManager`). `TELEGRAM_TOKEN` and `TELEGRAM_TOKEN_SECRET_NAME` remain repository-specific.
218217
- If `IB_ACCOUNT_GROUP_CONFIG_SECRET_NAME` is set, the Cloud Run runtime needs Secret Manager access to that secret.
219-
- `GCP_SA_KEY` belongs to the GitHub Actions deploy identity, not to the Cloud Run runtime service account.
218+
- GitHub now authenticates to Google Cloud with OIDC + Workload Identity Federation, so `GCP_SA_KEY` is no longer required for this workflow.
220219

221220
### Deployment unit and naming
222221

@@ -417,7 +416,6 @@ IB_GATEWAY_IP_MODE=internal
417416
- `GLOBAL_TELEGRAM_CHAT_ID`
418417
- `NOTIFY_LANG`
419418
- **仓库级 Secrets**
420-
- `GCP_SA_KEY`
421419
- `TELEGRAM_TOKEN`(仅在没设置 `TELEGRAM_TOKEN_SECRET_NAME` 时作为 fallback)
422420
- **可选过渡 Variables**
423421
- `IB_GATEWAY_ZONE`
@@ -430,9 +428,9 @@ IB_GATEWAY_IP_MODE=internal
430428
注意:
431429

432430
- 只有在 `ENABLE_GITHUB_ENV_SYNC=true` 时,这个 workflow 才会严格校验并执行同步。没打开时会直接跳过。
433-
- 这里说的“共享配置”仍然只针对 **IBKR 这一组系统**`GCP_SA_KEY``TELEGRAM_TOKEN``TELEGRAM_TOKEN_SECRET_NAME` 都还是这个仓库自己的配置,不建议提升成所有 quant 共用的全局配置。
431+
- 这里说的“共享配置”仍然只针对 **IBKR 这一组系统**`TELEGRAM_TOKEN``TELEGRAM_TOKEN_SECRET_NAME` 都还是这个仓库自己的配置,不建议提升成所有 quant 共用的全局配置。
434432
- 如果设置了 `IB_ACCOUNT_GROUP_CONFIG_SECRET_NAME`,Cloud Run 运行时还需要有对应 Secret 的访问权限。
435-
- `GCP_SA_KEY` 对应的是 GitHub Actions 的部署身份,不是 Cloud Run runtime service account
433+
- GitHub 现在通过 OIDC + Workload Identity Federation 登录 Google Cloud,这个 workflow 不再需要 `GCP_SA_KEY`
436434

437435
### 部署单元和命名建议
438436

docs/ibkr_runtime_rollout.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,11 @@ gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
186186

187187
### Repository Secrets
188188

189-
- `GCP_SA_KEY`
190189
- `TELEGRAM_TOKEN`(仅在没设置 `TELEGRAM_TOKEN_SECRET_NAME` 时作为 fallback)
191190

192191
说明:
193192

194-
- `GCP_SA_KEY` 对应的是 **GitHub Actions 用的部署账号**,不是 Cloud Run runtime service account
193+
- GitHub 现在通过 OIDC + Workload Identity Federation 登录 Google Cloud,这个 workflow 不再需要 `GCP_SA_KEY`
195194
- 如果你现在只用这个 workflow 做“同步已有 Cloud Run service 的 env”,那这个 GitHub Actions 账号只需要能更新目标 Cloud Run service,不需要现在就补 Cloud Build / Artifact Registry 那一套权限。
196195

197196
## 5. 先把 `ACCOUNT_GROUP=default` 跑通的顺序

0 commit comments

Comments
 (0)