Skip to content

Commit 05085b1

Browse files
committed
Address cpflow review app follow-ups
1 parent 897c42d commit 05085b1

3 files changed

Lines changed: 35 additions & 10 deletions

File tree

.controlplane/readme.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ 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.
383383
The production promotion workflow checks that production has all environment
384-
variable names present in staging; it does not compare secret values.
384+
variable names present in staging; it does not compare secret values, workload
385+
environment variables, or Control Plane secret references.
385386

386387
The repository variables and secrets must match the app names in
387388
`.controlplane/controlplane.yml`. In particular, `REVIEW_APP_PREFIX` should
@@ -426,7 +427,17 @@ bundle exec rubocop
426427
```
427428

428429
Then open a normal PR and let GitHub Actions prove the generated review-app,
429-
staging, lint, JS, and RSpec workflows before merging. If a project needs to
430-
track generator changes automatically, use a scheduled maintenance PR or
431-
Renovate-style workflow that bumps the `cpflow` version, regenerates these files,
432-
and runs the same validation commands.
430+
staging, lint, JS, and RSpec workflows before merging. For review-app workflow
431+
changes, test both the local workflow syntax and a real deployment. GitHub runs
432+
`issue_comment` workflows from the default branch, so a `/deploy-review-app`
433+
comment on the PR does not fully exercise slash-command changes that are only on
434+
the PR branch. Before merge, run the PR branch workflow explicitly:
435+
436+
```bash
437+
gh workflow run cpflow-deploy-review-app.yml --ref <branch> -f pr_number=<pr-number>
438+
```
439+
440+
After the workflow reports a review-app URL, verify the URL returns HTTP 200.
441+
If a project needs to track generator changes automatically, use a scheduled
442+
maintenance PR or Renovate-style workflow that bumps the `cpflow` version,
443+
regenerates these files, and runs the same validation commands.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
timeout-minutes: 45
5252

5353
steps:
54+
# `pull_request` events run in the base repository context, so this initial
55+
# checkout fetches trusted workflow code before the fork-origin guard below.
5456
- name: Initial checkout
5557
uses: actions/checkout@v4
5658

@@ -107,6 +109,8 @@ jobs:
107109
same_repo="true"
108110
fi
109111
112+
# Re-derive these from the resolved PR number because workflow-level env
113+
# values are empty for issue_comment events.
110114
{
111115
echo "PR_NUMBER=$pr_number"
112116
echo "APP_NAME=${REVIEW_APP_PREFIX}-$pr_number"

.github/workflows/cpflow-promote-staging-to-production.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ on:
99
type: string
1010

1111
permissions:
12-
contents: write
12+
contents: write # Required for `gh release create` after a successful promotion.
1313

1414
env:
1515
# Override these by editing this file or by setting the matching repository variable.
1616
# Worst-case wall time per attempt is HEALTH_CHECK_INTERVAL plus the curl --max-time below
1717
# (10s), so the defaults give a ~10 minute window (24 × (15 + 10) = 600s) — enough for
1818
# most Rails cold boots (asset precompile + db:migrate + workload readiness).
19-
HEALTH_CHECK_RETRIES: 24
20-
HEALTH_CHECK_INTERVAL: 15
19+
HEALTH_CHECK_RETRIES: ${{ vars.HEALTH_CHECK_RETRIES || 24 }}
20+
HEALTH_CHECK_INTERVAL: ${{ vars.HEALTH_CHECK_INTERVAL || 15 }}
2121
# Space-separated list of HTTP statuses considered healthy. The default accepts 301/302
2222
# because `curl` is invoked without `-L`, so a root `/` that redirects to a login page
2323
# (common for Rails apps that auth-gate `/`) would otherwise be reported as unhealthy
@@ -26,8 +26,8 @@ env:
2626
# (e.g. "200" for a plain /health, or "200 401 403" for apps that auth-gate / without
2727
# redirecting).
2828
HEALTH_CHECK_ACCEPTED_STATUSES: ${{ vars.HEALTH_CHECK_ACCEPTED_STATUSES || '200 301 302' }}
29-
ROLLBACK_READINESS_RETRIES: 24
30-
ROLLBACK_READINESS_INTERVAL: 15
29+
ROLLBACK_READINESS_RETRIES: ${{ vars.ROLLBACK_READINESS_RETRIES || 24 }}
30+
ROLLBACK_READINESS_INTERVAL: ${{ vars.ROLLBACK_READINESS_INTERVAL || 15 }}
3131
PRIMARY_WORKLOAD: ${{ vars.PRIMARY_WORKLOAD }}
3232

3333
concurrency:
@@ -128,19 +128,27 @@ jobs:
128128
staging_vars="$(CPLN_TOKEN="${CPLN_TOKEN_STAGING}" cpln gvc get "${STAGING_APP_NAME}" --org "${CPLN_ORG_STAGING}" -o json | jq -r '.spec.env // [] | .[].name' | sort)"
129129
production_vars="$(CPLN_TOKEN="${CPLN_TOKEN_PRODUCTION}" cpln gvc get "${PRODUCTION_APP_NAME}" --org "${CPLN_ORG_PRODUCTION}" -o json | jq -r '.spec.env // [] | .[].name' | sort)"
130130
131+
# This compares GVC-level env var names only. Workload-level env entries
132+
# and secret references are outside this pre-flight check's scope.
131133
if [[ -z "${staging_vars}" ]]; then
132134
echo "Staging GVC exposes no environment variables; skipping parity check."
133135
exit 0
134136
fi
135137
136138
missing_vars="$(comm -23 <(printf '%s\n' "${staging_vars}") <(printf '%s\n' "${production_vars}"))"
139+
extra_vars="$(comm -13 <(printf '%s\n' "${staging_vars}") <(printf '%s\n' "${production_vars}"))"
137140
138141
if [[ -n "${missing_vars}" ]]; then
139142
echo "::error::Production is missing environment variables that exist in staging"
140143
echo "${missing_vars}"
141144
exit 1
142145
fi
143146
147+
if [[ -n "${extra_vars}" ]]; then
148+
echo "::warning::Production has GVC environment variables that do not exist in staging; verify they are intentional:"
149+
echo "${extra_vars}"
150+
fi
151+
144152
- name: Capture current production image
145153
id: capture-current
146154
env:
@@ -258,6 +266,8 @@ jobs:
258266
rollback_args=()
259267
260268
while IFS=$'\t' read -r index image; do
269+
# cpln parses --set as key=value; current image URI formats do not
270+
# contain "=", but re-check this if digest-pinned refs ever add one.
261271
rollback_args+=(--set "spec.containers[${index}].image=${image}")
262272
done < <(echo "${previous_images}" | jq -r 'to_entries[] | "\(.key)\t\(.value)"')
263273

0 commit comments

Comments
 (0)