You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
missing_vars+=("TELEGRAM_TOKEN_SECRET_NAME or TELEGRAM_TOKEN")
69
67
fi
70
68
71
-
if [ -z "${LONGPORT_APP_KEY_SECRET_NAME:-}" ] && [ -z "${LONGPORT_APP_KEY:-}" ]; then
72
-
missing_vars+=("LONGPORT_APP_KEY_SECRET_NAME or LONGPORT_APP_KEY")
69
+
if [ -z "${LONGPORT_APP_KEY_SECRET_NAME:-}" ]; then
70
+
missing_vars+=("LONGPORT_APP_KEY_SECRET_NAME")
73
71
fi
74
72
75
-
if [ -z "${LONGPORT_APP_SECRET_SECRET_NAME:-}" ] && [ -z "${LONGPORT_APP_SECRET:-}" ]; then
76
-
missing_vars+=("LONGPORT_APP_SECRET_SECRET_NAME or LONGPORT_APP_SECRET")
73
+
if [ -z "${LONGPORT_APP_SECRET_SECRET_NAME:-}" ]; then
74
+
missing_vars+=("LONGPORT_APP_SECRET_SECRET_NAME")
77
75
fi
78
76
79
77
if [ "${#missing_vars[@]}" -gt 0 ]; then
80
78
echo "enabled=false" >> "$GITHUB_OUTPUT"
81
79
echo "HK Cloud Run env sync is enabled, but these values are missing:" >&2
82
80
echo " - If HK and SG run in different regions, set CLOUD_RUN_REGION on the longbridge-hk Environment." >&2
81
+
echo " - Set LONGPORT_APP_KEY_SECRET_NAME and LONGPORT_APP_SECRET_SECRET_NAME on the longbridge-hk Environment so HK does not fall back to shared repository defaults." >&2
83
82
printf ' - %s\n' "${missing_vars[@]}" >&2
84
83
exit 1
85
84
fi
@@ -129,21 +128,11 @@ jobs:
129
128
remove_secret_vars+=("TELEGRAM_TOKEN")
130
129
fi
131
130
132
-
if [ -n "${LONGPORT_APP_KEY_SECRET_NAME:-}" ]; then
missing_vars+=("TELEGRAM_TOKEN_SECRET_NAME or TELEGRAM_TOKEN")
221
208
fi
222
209
223
-
if [ -z "${LONGPORT_APP_KEY_SECRET_NAME:-}" ] && [ -z "${LONGPORT_APP_KEY:-}" ]; then
224
-
missing_vars+=("LONGPORT_APP_KEY_SECRET_NAME or LONGPORT_APP_KEY")
210
+
if [ -z "${LONGPORT_APP_KEY_SECRET_NAME:-}" ]; then
211
+
missing_vars+=("LONGPORT_APP_KEY_SECRET_NAME")
225
212
fi
226
213
227
-
if [ -z "${LONGPORT_APP_SECRET_SECRET_NAME:-}" ] && [ -z "${LONGPORT_APP_SECRET:-}" ]; then
228
-
missing_vars+=("LONGPORT_APP_SECRET_SECRET_NAME or LONGPORT_APP_SECRET")
214
+
if [ -z "${LONGPORT_APP_SECRET_SECRET_NAME:-}" ]; then
215
+
missing_vars+=("LONGPORT_APP_SECRET_SECRET_NAME")
229
216
fi
230
217
231
218
if [ "${#missing_vars[@]}" -gt 0 ]; then
232
219
echo "enabled=false" >> "$GITHUB_OUTPUT"
233
220
echo "SG Cloud Run env sync is enabled, but these values are missing:" >&2
234
221
echo " - If HK and SG run in different regions, set CLOUD_RUN_REGION on the longbridge-sg Environment." >&2
222
+
echo " - Set LONGPORT_APP_KEY_SECRET_NAME and LONGPORT_APP_SECRET_SECRET_NAME on the longbridge-sg Environment so SG does not fall back to shared repository defaults." >&2
235
223
printf ' - %s\n' "${missing_vars[@]}" >&2
236
224
exit 1
237
225
fi
@@ -281,21 +269,11 @@ jobs:
281
269
remove_secret_vars+=("TELEGRAM_TOKEN")
282
270
fi
283
271
284
-
if [ -n "${LONGPORT_APP_KEY_SECRET_NAME:-}" ]; then
|`TELEGRAM_TOKEN`| Yes | Bot token for alerts; recommended to inject from Secret Manager secret `longbridge-telegram-token`|
83
83
|`GLOBAL_TELEGRAM_CHAT_ID`| Yes | Telegram chat or user ID used by this service. |
84
-
|`LONGPORT_APP_KEY`| Yes | LongPort OpenAPI app key (for token refresh); recommended to inject from Secret Manager secret `longport-app-key`|
85
-
|`LONGPORT_APP_SECRET`| Yes | LongPort OpenAPI app secret (for token refresh); recommended to inject from Secret Manager secret `longport-app-secret`|
84
+
|`LONGPORT_APP_KEY`| Yes | LongPort OpenAPI app key (for token refresh); recommended to inject from the region-specific Secret Manager secret for this deployment, such as `longport-app-key-hk` / `longport-app-key-sg`|
85
+
|`LONGPORT_APP_SECRET`| Yes | LongPort OpenAPI app secret (for token refresh); recommended to inject from the region-specific Secret Manager secret for this deployment, such as `longport-app-secret-hk` / `longport-app-secret-sg`|
86
86
|`LONGPORT_SECRET_NAME`| No | Secret Manager secret name for LongPort token (default: `longport_token_hk`) |
87
87
|`ACCOUNT_PREFIX`| No | Alert/log prefix for account/environment (default: `DEFAULT`) |
88
88
|`SERVICE_NAME`| No | Alert/log prefix for service identity (default: `longbridge-quant-semiconductor-rotation-income`) |
Secret Manager must contain the secret named by `LONGPORT_SECRET_NAME` (default: `longport_token_hk`), where the **latest version = active access token**. The app refreshes it when expiry is within 30 days.
95
95
96
-
Recommended shared runtime secrets in the `longbridgequant` project:
96
+
Recommended runtime secrets in the `longbridgequant` project:
On every push to `main`, the workflow updates both Cloud Run services with the shared and per-environment values above, and removes `TELEGRAM_CHAT_ID` from each Cloud Run service.
140
140
141
141
Important:
142
142
143
143
-`CLOUD_RUN_REGION` should be set on each GitHub Environment, not as one shared repository variable. This lets `HK` and `SG` live in different Cloud Run regions.
144
+
-`LONGPORT_APP_KEY_SECRET_NAME` and `LONGPORT_APP_SECRET_SECRET_NAME` should also be set on each GitHub Environment. Do not keep one repository-level default for them when `HK` and `SG` use different LongPort credentials.
144
145
- The workflow only becomes strict when `ENABLE_GITHUB_ENV_SYNC=true`. If this variable is unset, the sync job is skipped and the old Google Cloud Trigger-only setup keeps working. Once you set it to `true`, missing env-sync values become a hard failure so you do not get a false green deployment.
145
146
- GitHub now authenticates to Google Cloud with OIDC + Workload Identity Federation, so `GCP_SA_KEY` is no longer required for this workflow.
146
-
- Here "shared" only means **shared inside this repository** between the `HK` and `SG` Cloud Run services. The Telegram token and LongPort app credentials should live in Secret Manager and be referenced by the shared secret-name variables above; they are not meant to be a global secret set reused by unrelated quant repos.
147
+
- Here "shared" only means **shared inside this repository** between the `HK` and `SG` Cloud Run services. The Telegram token can still be shared, but LongPort app credentials should live in Secret Manager and be referenced by per-environment secret-name variables; they are not meant to be a global secret set reused by unrelated quant repos.
147
148
- If you want one cross-project shared layer across multiple quant repos, keep it small: `GLOBAL_TELEGRAM_CHAT_ID` and `NOTIFY_LANG` are reasonable; account credentials and deployment keys are not.
148
149
149
150
### Deployment unit and naming
@@ -162,7 +163,7 @@ Important:
162
163
4. Deploy the app to Cloud Run (e.g. `gcloud run deploy` from repo root with Dockerfile or buildpack).
163
164
5. Create a Cloud Scheduler job that POSTs to the Cloud Run URL on a schedule (e.g. `45 15 * * 1-5` for ~15 min before US market close on weekdays).
164
165
165
-
IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Accessor for the configured `LONGPORT_SECRET_NAME`, such as `longport_token_hk` / `longport_token_sg`) and **Logs Writer**. Build/deploy typically uses a separate account with Artifact Registry Writer, Cloud Run Admin, Service Account User.
166
+
IAM: the Cloud Run service account needs **Secret Manager Admin** (or Secret Accessor for the configured `LONGPORT_SECRET_NAME`, `LONGPORT_APP_KEY_SECRET_NAME`, and `LONGPORT_APP_SECRET_SECRET_NAME`, such as `longport_token_hk`, `longport-app-key-hk`, `longport-app-secret-hk`) and **Logs Writer**. Build/deploy typically uses a separate account with Artifact Registry Writer, Cloud Run Admin, Service Account User.
0 commit comments