Repository navigation
ci: deploy only after CI has passed for the commit - #246
Merged
Merged
Conversation
CD triggered on any push to main with nothing connecting it to CI, so the two ran in parallel and the deploy normally finished first. A commit whose tests failed still reached rexial.in, which made every check in CI — the type gate, the tests across five services, the secret scan — advisory: they reported on something already live. Trigger CD from CI completing on main instead, and refuse to run unless the conclusion was success. A manual redeploy has no triggering run, so the guard allows workflow_dispatch explicitly and that path is unchanged. Under workflow_run, github.sha is the default branch tip rather than the commit CI tested. Those are the same thing most of the time and different exactly when it matters — a second merge landing while the first is still deploying. Every job now pins DEPLOY_SHA, including the checkout, so the images built, the images pulled and the commit the server resets to all refer to the commit that actually passed. Branch protection on main is the other half of this and is a repository setting rather than code; tracked in #241.
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.
Closes the code half of #241.
What does this PR do?
CD triggered on any push to
mainwith nothing connecting it to CI, so the two ran in parallel — and the deploy normally finished first. A commit whose tests failed still reached rexial.in.That made every check in CI advisory: the type gate, the tests across five services, the secret scan, the compose validation. All of it reported on something already live.
CD now triggers from CI completing on
main, and refuses to run unless the conclusion wassuccess:Behaviour across every CI outcome:
workflow_dispatch)The part worth reviewing
Under
workflow_run,github.shais the default branch tip, not the commit CI tested. Those are the same thing most of the time and different exactly when it matters — a second merge landing while the first is still deploying.Left alone, that would have built images from one commit while the server reset to another. So every job now pins a single
DEPLOY_SHA:including the
actions/checkoutref, the image tags, the Trivy scan target, thegit reset --hardon the server andIMAGE_TAG. The fallback keeps manual redeploys working, since those have no triggering run.Not in this PR
Branch protection on
mainis the other half of #241 and is a repository setting rather than code — requiring a pull request, requiring the CI checks, and disallowing force pushes. Without it, a direct push tomainstill lands; it just will not deploy unless CI passes.Leaving #241 open until that side is done too.
Type of change
How did you test this?
yaml.safe_loadon the workflow, and the parsed structure checked: triggers, theifguard, and thatdeploystillneeds: build-and-pushso the guard propagates.CIand runs on push tomain, soworkflow_runwill fire.github.sharemains outside theDEPLOY_SHAdefinition.The first merge after this lands is the real test: CD should start only once CI reports green, and the logs should name the same SHA throughout.