Skip to content

ci: deploy backend to Fly only after CI passes on main - #650

Merged
madara88645 merged 1 commit into
mainfrom
ci/gate-fly-deploy-on-ci
Oct 23, 2026
Merged

madara88645 merged 1 commit into
mainfrom
ci/gate-fly-deploy-on-ci

Conversation

@madara88645

Copy link
Copy Markdown
Owner

What

Gate the Fly.io backend deploy on a fully green CI run on main.

  • .github/workflows/fly.yml becomes a reusable workflow. It is now triggered by workflow_call (new) and workflow_dispatch (unchanged). The push trigger and its paths filter are removed. These are unchanged: the job, steps, permissions, concurrency group (fly-production, cancel-in-progress), token sanitizing step, flyctl deploy and the post-deploy health check.
  • .github/workflows/ci.yml gets two new jobs that only do anything for pushes to main:
    • backend-changes ("Detect backend changes") checks out full history. It compares the whole push range github.event.before..github.sha against the paths fly.yml used 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 a deploy output. It defaults to deploying when before is 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 plus backend-changes. It runs only when they all succeeded and deploy == 'true'. It calls ./.github/workflows/fly.yml with secrets: inherit and contents: read.

Why

Until now, Fly Deploy ran on every push to main in parallel with CI. A merge could reach production even when lint, security, tests, type checks or the frontend build failed on main.

New flow

  1. A PR is merged and CI starts on the push to main.
  2. The five existing jobs run as before, with backend-changes running alongside them.
  3. If all five pass and the push range touched a deploy-relevant path, deploy-backend calls the Fly workflow. It deploys the exact commit CI tested, then runs the health check.
  4. If any CI job fails or is cancelled, or the push did not touch backend paths, deploy-backend is skipped.

What triggers a deploy now

  • A push to main that changes any of the paths above, once every CI job on that run has succeeded.
  • A manual run of Actions → Fly Deploy → Run workflow (workflow_dispatch). This stays for emergencies and is not gated on CI.

What no longer triggers a deploy

  • A push to main whose CI run fails. Before this PR it still deployed.
  • Frontend-, docs- and test-only merges still do not deploy, the same as before, because of the paths check. I replayed the last 120 CI push runs on main: each time, the new check chose to deploy exactly when a Fly Deploy run existed (120/120).

Pull requests

PR runs are unchanged. They run the same five jobs under the same names. (main currently 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.yml is 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

  • Automated deploys now appear as the Deploy backend job inside CI runs on main. The Fly Deploy run list will only show manual runs.
  • A failed deploy or health check now fails the CI run on main, and the README CI badge turns red until the next green run.

Known limitations

  • Suppose CI fails on main after 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 manual Fly Deploy. Re-running the failed CI run only helps if the failure was a flake, because a re-run tests the same commit.
  • A deploy now starts when CI finishes, not when the push lands. CI on main takes 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 through cancel-in-progress, leaving production on the older commit. The cancelled deploy shows up as a cancelled CI run on main. 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 manual Fly Deploy from main.

Validation

Out of scope

  • Vercel frontend deploys (explorer/) are separate and not gated by this change.
  • No branch-protection changes.
  • fly.toml, Dockerfiles, secrets and app code are untouched.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vibegraph Ready Ready Preview Oct 23, 2026 7:55pm UTC

@madara88645
madara88645 marked this pull request as ready for review October 23, 2026 19:57
@madara88645
madara88645 merged commit 25bd655 into main Oct 23, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 67183368 Deployed Oct 23, 2026 by vercel[bot]
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