Skip to content

feat(ci): deploy to prod automatically on merge to main#3007

Open
cqnykamp wants to merge 4 commits into
Doenet:mainfrom
cqnykamp:auto-prod-deploy
Open

feat(ci): deploy to prod automatically on merge to main#3007
cqnykamp wants to merge 4 commits into
Doenet:mainfrom
cqnykamp:auto-prod-deploy

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

Summary

Makes production deployment fully automatic: merging a PR to main now deploys to prod immediately, with no CI re-run on main and no manual approval step.

Why this is safe: branch protection requires PR branches to be up to date with main, so the tree that lands on main is content-identical to what the PR's required checks already tested. Re-running CI on main and waiting for a human click added ~30–60 minutes of latency without adding information.

Changes

  • Trigger on push to main instead of workflow_run on CI completion; deploy github.sha directly.
  • Remove the approve job. Nothing references the prod environment's protection rules anymore, so deploys can't be gated by them. (Follow-up for repo settings: the required-reviewer rule on the prod environment is now inert and can be removed.)
  • cancel-in-progress: false. Merging PR B while PR A's ~10-minute deploy is mid-flight previously canceled A mid-S3-sync / mid-ECS-rollout — potentially killing the rollback logic itself. Now A finishes, and GitHub queues only the newest pending run (which, per branch protection, contains every earlier merge). Intermediate pending runs are superseded before they start, which is harmless.
  • Record deployments on the prod GitHub Environment, mirroring dev3's pattern: open a deployment via the Deployments API, mark in_progress at start, finalize with a success/failure rollup (per-component results in the description) after backend/frontend/site complete. Bookkeeping is best-effort and no deploy job depends on it, so an API hiccup can never block or skip a deploy. On success GitHub auto-inactivates the previous record, so the Environments tab always shows what's live.
  • Remove the tag-prod job. The deployment record supersedes the force-pushed prod tag (nothing in the repo reads it). The stale tag on the remote can be deleted separately: git push origin :refs/tags/prod.

Operational notes

  • Deploy gate is now the PR required-checks list. Worth verifying it includes every CI job (check + all e2e-tests, e2e-brittle-tests, component-tests matrix entries) and that direct pushes to main are blocked, since any push to main now ships.
  • Rollback path: revert the PR, or re-run the last good Prod Deploy workflow run (redeploys that SHA). Backend additionally keeps its existing ECS stabilization + image-retag rollback.
  • CI still runs on main pushes as a signal; it no longer gates anything.

🤖 Generated with Claude Code

cqnykamp and others added 4 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>
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