Repository navigation
ci: deploy backend to Fly only after CI passes on main - #650
Merged
Merged
Conversation
The Fly Deploy workflow ran on every push to main in parallel with CI, so a merge could reach production even when lint, tests or the build failed on main. Turn fly.yml into a reusable workflow (workflow_call, plus the existing workflow_dispatch for manual deploys) and call it from a new deploy-backend job in ci.yml. That job needs all five CI jobs and a new backend-changes job, which runs only for pushes to main and checks the whole push range (before..sha) against the paths that fly.yml used to filter on. A missing, all-zero or non-ancestor 'before' (new branch, force push) defaults to deploying. Pull request runs skip both new jobs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
madara88645
marked this pull request as ready for review
October 23, 2026 19:57
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Gate the Fly.io backend deploy on a fully green CI run on
main..github/workflows/fly.ymlbecomes a reusable workflow. It is now triggered byworkflow_call(new) andworkflow_dispatch(unchanged). Thepushtrigger and itspathsfilter are removed. These are unchanged: the job, steps, permissions, concurrency group (fly-production, cancel-in-progress), token sanitizing step,flyctl deployand the post-deploy health check..github/workflows/ci.ymlgets two new jobs that only do anything for pushes tomain:backend-changes("Detect backend changes") checks out full history. It compares the whole push rangegithub.event.before..github.shaagainst the pathsfly.ymlused to filter on:app/,teacher/,analyst/,serve.py,main.py,requirements.txt,Dockerfile.fly,fly.toml,.github/workflows/fly.yml. It prints the matched paths and exposes adeployoutput. It defaults to deploying whenbeforeis empty, all zeros, unknown, or not an ancestor of the new head (new branch, force push).deploy-backend("Deploy backend") needs all five existing CI jobs plusbackend-changes. It runs only when they all succeeded anddeploy == 'true'. It calls./.github/workflows/fly.ymlwithsecrets: inheritandcontents: read.Why
Until now,
Fly Deployran on every push tomainin parallel withCI. A merge could reach production even when lint, security, tests, type checks or the frontend build failed onmain.New flow
CIstarts on the push tomain.backend-changesrunning alongside them.deploy-backendcalls the Fly workflow. It deploys the exact commit CI tested, then runs the health check.deploy-backendis skipped.What triggers a deploy now
mainthat changes any of the paths above, once every CI job on that run has succeeded.workflow_dispatch). This stays for emergencies and is not gated on CI.What no longer triggers a deploy
mainwhose CI run fails. Before this PR it still deployed.main: each time, the new check chose to deploy exactly when aFly Deployrun existed (120/120).Pull requests
PR runs are unchanged. They run the same five jobs under the same names. (
maincurrently has no branch protection or rulesets, so there are no required checks to break either way.) The two new jobs show as skipped on PRs and never reach the deploy.Merging this PR
.github/workflows/fly.ymlis in the deploy paths list. So once CI is green, merging this PR deploys through the new path (deploy-backend→ Fly). That first run is the real end-to-end test, so please watch it.Behaviour changes to know about
CIruns onmain. TheFly Deployrun list will only show manual runs.CIrun onmain, and the README CI badge turns red until the next green run.Known limitations
mainafter a backend change, and the fix touches only non-backend files (e.g.tests/). Then the backend change is not deployed until the next backend push. To ship it sooner, start a manualFly Deploy. Re-running the failed CI run only helps if the failure was a flake, because a re-run tests the same commit.maintakes about 45–67 s. If two backend merges land only seconds apart, an older commit's deploy could start after a newer one's and cancel it throughcancel-in-progress, leaving production on the older commit. The cancelled deploy shows up as a cancelledCIrun onmain. In past merge bursts (e.g. four backend merges within 16 s on 2026-06-04) CI finished in push order, so this has not happened yet. If it does, start a manualFly Deployfrommain.Validation
actionlint1.7.12 is clean on both files, including its shellcheck integration. Standaloneshellcheckon the detection script is also clean.ci.ymland ran it withbash -eagainst real history:app/__init__.py): deployrequirements.txt+fly.yml): deployapp/routers/upload.py,app/utils/security.py): deploy.jules/changes: no deploybefore: deployapp.py,apps/,sub/serve.py,fly.yml.bak) do not matchapp/does matchOut of scope
explorer/) are separate and not gated by this change.fly.toml, Dockerfiles, secrets and app code are untouched.🤖 Generated with Claude Code