fix(legacy): keep github app secrets in production (#63423)

This commit is contained in:
Dax
2026-11-11 19:49:20 -05:00
committed by GitHub
Unverified
parent 6d023043ca
commit b451fe3952
6 changed files with 25 additions and 18 deletions
+9 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# deploy-legacy.sh <dev|production> <dir> <secrets.json>: deploys the legacy
# deploy-legacy.sh <dev|production> <dir> [production-secrets.json]: deploys the legacy
# Worker from a verified Build Output artifact (services/legacy/.cloudflare/output)
# with the cf CLI pinned in cf/package-lock.json.
#
@@ -12,7 +12,6 @@
mode=$1
src=$(cd "$2" && pwd)
secrets=$(posix "$3")
release=$(cd "$(dirname "$0")" && pwd)
case "$mode" in
@@ -37,8 +36,13 @@ unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256
expect_json "$src/v0/config.json" "$target/root.json" "The legacy Worker's root config"
expect_json "$src/v0/workers/default/worker.config.json" "$target/worker.json" "The legacy Worker's config"
jq -e 'keys == ["GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY"] and all(.[]; type == "string" and length > 0)' \
"$secrets" > /dev/null || die "The secrets file does not hold exactly GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY"
args=()
if [[ "$mode" == production ]]; then
secrets=$(posix "$3")
jq -e 'keys == ["GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY"] and all(.[]; type == "string" and length > 0)' \
"$secrets" > /dev/null || die "The secrets file does not hold exactly GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY"
args=(--secrets-file "$secrets")
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
@@ -52,4 +56,4 @@ cf="$release/cf/node_modules/.bin/cf"
[ -x "$cf" ] || die "Install the pinned cf CLI first: npm ci --ignore-scripts in .github/release/cf"
cd "$work"
"$cf" deploy --prebuilt --mode "$mode" --secrets-file "$secrets"
"$cf" deploy --prebuilt --mode "$mode" "${args[@]}"
@@ -7,10 +7,6 @@
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"GITHUB_APP_ID": { "type": "secret" },
"GITHUB_APP_PRIVATE_KEY": { "type": "secret" }
},
"manifest": {
"type": "complete",
"mainModule": "index.js",
+4 -1
View File
@@ -109,11 +109,14 @@ jobs:
# An explicit bash runs with pipefail, so a failed secret read fails the step.
shell: bash
run: |
if [[ "$STAGE" == dev ]]; then
exec bash .github/release/deploy-legacy.sh dev "$RUNNER_TEMP/in/legacy-dev"
fi
umask 077
secrets="$RUNNER_TEMP/legacy-secrets.json"
trap 'rm -f "$secrets"' EXIT
for name in GITHUB_APP_ID GITHUB_APP_PRIVATE_KEY; do
aws secretsmanager get-secret-value --secret-id "opencode/$STAGE/$name" --output json |
aws secretsmanager get-secret-value --secret-id "opencode/production/$name" --output json |
jq --arg name "$name" '{($name): .SecretString}'
done | jq -s add > "$secrets"
bash .github/release/deploy-legacy.sh "$STAGE" "$RUNNER_TEMP/in/legacy-$STAGE" "$secrets"