Skip to content

Commit b9095c6

Browse files
committed
Harden cpflow review app workflow
1 parent eb1dbb2 commit b9095c6

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

.controlplane/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ After the review app exists, new pushes to the PR redeploy it automatically.
380380
Use `/delete-review-app` to delete it manually; closing the PR deletes it
381381
automatically. Pushes to the staging branch deploy staging, and production
382382
promotion is manual from the `cpflow-promote-staging-to-production` workflow.
383+
The production promotion workflow checks that production has all environment
384+
variable names present in staging; it does not compare secret values.
383385

384386
The repository variables and secrets must match the app names in
385387
`.controlplane/controlplane.yml`. In particular, `REVIEW_APP_PREFIX` should

.github/workflows/cpflow-deploy-review-app.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
echo "Control Plane review app automation is not configured yet."
7373
echo
7474
echo "Missing required GitHub configuration:"
75-
printf -- '- `%s`\n' "${missing[@]}"
75+
printf -- '- %s\n' "${missing[@]}"
7676
echo
7777
echo "Pushes to this pull request will skip review app deploys until the repository is configured."
7878
} >> "$GITHUB_STEP_SUMMARY"
@@ -119,9 +119,11 @@ jobs:
119119
same_repo="true"
120120
fi
121121
122-
echo "PR_NUMBER=$pr_number" >> "$GITHUB_ENV"
123-
echo "APP_NAME=${{ vars.REVIEW_APP_PREFIX }}-$pr_number" >> "$GITHUB_ENV"
124-
echo "PR_SHA=$pr_sha" >> "$GITHUB_ENV"
122+
{
123+
echo "PR_NUMBER=$pr_number"
124+
echo "APP_NAME=${{ vars.REVIEW_APP_PREFIX }}-$pr_number"
125+
echo "PR_SHA=$pr_sha"
126+
} >> "$GITHUB_ENV"
125127
echo "same_repo=${same_repo}" >> "$GITHUB_OUTPUT"
126128
127129
- name: Validate review app deployment source
@@ -182,9 +184,26 @@ jobs:
182184
run: |
183185
set -euo pipefail
184186
185-
if cpflow exists -a "${APP_NAME}" --org "${CPLN_ORG}"; then
187+
exists_output=""
188+
if exists_output="$(cpflow exists -a "${APP_NAME}" --org "${CPLN_ORG}" 2>&1)"; then
189+
if [[ -n "${exists_output}" ]]; then
190+
printf '%s\n' "${exists_output}"
191+
fi
192+
186193
echo "exists=true" >> "$GITHUB_OUTPUT"
187194
else
195+
case "${exists_output}" in
196+
*"Double check your org"*|*"Unknown API token format"*|*"ERROR"*|*"Error:"*|*"Traceback"*|*"Net::"*)
197+
echo "Failed to determine whether review app exists: ${APP_NAME}" >&2
198+
printf '%s\n' "${exists_output}" >&2
199+
exit 1
200+
;;
201+
esac
202+
203+
if [[ -n "${exists_output}" ]]; then
204+
printf '%s\n' "${exists_output}"
205+
fi
206+
188207
echo "exists=false" >> "$GITHUB_OUTPUT"
189208
fi
190209

0 commit comments

Comments
 (0)