Skip to content

refactor(ci): deduplicate deploy workflows#3008

Open
cqnykamp wants to merge 5 commits into
Doenet:mainfrom
cqnykamp:refactor-deploy-workflows
Open

refactor(ci): deduplicate deploy workflows#3008
cqnykamp wants to merge 5 commits into
Doenet:mainfrom
cqnykamp:refactor-deploy-workflows

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

Stacked on #3007 — this branch includes that PR's commits; the diff shrinks to just the refactor once #3007 merges.

Summary

The three deploy entry points (dev-deploy.yml, dev-deploy-pr.yml, prod-deploy.yml) each repeated two things:

  1. The backend/frontend/site fan-out, ~40 lines of per-environment constants per caller (account IDs, role ARNs, ECR repo, cluster, SNS topic, tag).
  2. The GitHub deployment bookkeeping bash (open + finalize), six near-identical blocks that had already drifted between copies (lights-out handling in dev, production_environment badge in prod).

No behavior change intended for any entry point.

Changes

  • reusable-deploy-env.yml — the single definition of what "a deploy" is. Takes deploy_ref + env_name, resolves all per-environment constants in one config job (the only place the two AWS accounts are named), fans out to the three existing component workflows, and exposes backend_result / frontend_result / site_result as outputs. Callers shrink to trigger/gate logic plus one deploy job. Adding a component or a smoke-test to "a deploy" is now a one-file edit.
  • .github/actions/open-deployment — opens a deployment record and marks it in_progress. Best-effort: never fails the job; empty deployment_id output means "no record, skip finalize". production-environment input covers prod's badge.
  • .github/actions/finalize-deployment — sets the final status from the three component results. The dev-only lights-out logic became an optional lights-parameter input: when set, a successful deploy while the environment is asleep is recorded as inactive; when unset (prod), plain success/failure. Any SSM read failure degrades to "treat as awake", which matches the old HAVE_AWS fallback.

Notes for review

  • Local composite actions require the repo on disk, so the bookkeeping jobs gained actions/checkout steps. In dev-deploy-pr.yml the checkout is conditioned on actually deploying, and issue_comment checks out the default branch, so the gate still never runs PR-controlled code.
  • Nesting depth is caller → deploy-env → component, within GitHub's 4-level reusable-workflow limit.
  • The status descriptions are now generated from the environment name (deployed to prod / dev3 deploy failed (backend:… frontend:… site:…)), matching the previous per-copy strings.
  • dev-deploy-pr.yml runs from the default branch on issue_comment, so its changes only take effect after merge. The push/dispatch paths can be exercised beforehand via gh workflow run dev-deploy.yml on this branch.

🤖 Generated with Claude Code

cqnykamp and others added 5 commits July 17, 2026 19:42
Prod previously waited for CI to re-run on main and then blocked on a
manual approval in the prod environment. Branch protection requires PRs
to be up to date with main, so the merged tree is content-identical to
what PR checks already tested — the re-run and the approval added
latency without adding safety.

- Trigger prod-deploy directly on push to main
- Drop the approve job; nothing references the prod environment's
  protection rules anymore
- Queue concurrent deploys instead of canceling in-progress ones, so a
  second merge can never kill a live deploy mid-rollout (GitHub keeps
  only the newest pending run, which contains all earlier merges)
- Record deployments on the prod GitHub Environment via the Deployments
  API, mirroring dev3: in_progress at start, success/failure rollup
  after all three deploys, best-effort so bookkeeping never blocks a
  deploy
- Remove the tag-prod job; the deployment record supersedes the
  force-pushed prod tag

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With deploys now automatic on merge, no human is in the loop when prod
breaks. Write down the two rollback paths (revert PR, re-run last green
Prod Deploy), the migration caveat that applies to both, and how to
verify what prod is actually serving.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The three deploy entry points (push to main -> dev3, /deploy-dev PR
command, push to main -> prod) each repeated two things: the
backend/frontend/site fan-out with its per-environment constants, and
the GitHub deployment bookkeeping bash, which had already drifted
between copies (lights-out handling, prod badge).

- reusable-deploy-env.yml: single definition of a deploy — resolves
  per-environment constants (account, role, ECR repo, cluster, SNS
  topic, tag) from env_name and fans out to the three component
  workflows; exposes per-component results as outputs
- actions/open-deployment: open a deployment record and mark it
  in_progress; best-effort, never fails the job
- actions/finalize-deployment: set the final status from the three
  component results, with an optional lights-parameter input that
  records success-while-asleep as inactive (dev3 only)
- callers shrink to trigger/gate logic plus one deploy job each

No behavior change intended for any of the three entry points.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant