Serial deployment jobs can still publish releases in the wrong order. An older commit may finish building later, enter the deployment queue last, and replace a newer release. Mutual exclusion protects simultaneous access; a separate freshness rule decides which candidate is still authorized to become current.
This article develops a deployment protocol through synthetic schedules. GitHub Actions concurrency behavior was checked on November 23, 2026, but no hosted workflow or deployment was executed. The protocol applies only when the deployment authority can enforce its stated generation check; a CI-side comparison alone cannot supply that guarantee.
Follow two builds that finish in reverse order
Imagine approved candidates A and B, with B intentionally superseding A. A's build takes longer. B finishes, obtains the deployment slot, and becomes active. A finishes afterward and obtains the same slot. If admission checks only whether another job is deploying, A is now allowed to replace B.
There was no overlap at the guarded step. The failure comes from treating queue order as release intent. Commit timestamps, build completion timestamps, and the order an operator approved candidates are different sequences. Decide which one is authoritative before writing the workflow condition.
For a single production target, a useful model is an explicit desired generation associated with an immutable artifact. Increasing that generation is an authorized change to release intent. A candidate carries the generation it was approved for, and the deployment authority checks it when accepting or activating the candidate.
This model is a design choice, not a native property of every deployment platform. If the platform cannot compare and activate atomically, use its supported conditional-update or orchestration mechanism. Otherwise document the race that remains instead of claiming the workflow prevents stale releases.
Match the concurrency group to the shared target
GitHub's concurrency documentation describes groups that limit participating jobs or workflows to one running member. Its default pending behavior replaces an existing pending member, and optional queue behavior changes pending capacity. Ordering by time spent waiting does not establish ordering by workflow dispatch or commit history.
Choose a group representing the resource being protected. A group containing a unique run identifier gives each run a separate lock. A group containing a branch can allow different branches to deploy to the same production target concurrently. Conversely, one group for independent preview environments can serialize work unnecessarily.
Inventory all writers to the target. A workflow guard has no effect on a manual deployment tool or another repository that does not participate. Keep the deployment authority's protection in place even if every current workflow uses the same group; future tools should not need to reproduce an undocumented convention to remain correct.
Cancellation deserves a separate policy. Canceling obsolete build work can save resources. Canceling a deployment midway can leave an operation whose remote outcome is unknown. Do not use the same cancellation rule for both merely because the YAML settings look similar.
Put freshness at the authoritative mutation
Consider desired generation 12 for artifact B. Candidate A presents generation 11. The authority rejects A before changing the active release. The observable denial result includes the current generation and a bounded explanation, without leaking sensitive deployment configuration. The active artifact remains B.
Now consider two candidates both authorized for generation 12. Give each request an operation identity and define whether an identical repeated request returns the existing operation or is rejected. A generation check alone does not establish request idempotency. The idempotent write guide covers that separate contract.
There can also be a gap between accepting an operation and activating its artifact. If generation 13 becomes desired while generation 12 is still preparing, the activation step must consult the chosen freshness policy. For a latest-desired policy, a stale worker needs fencing at the final pointer update; checking only at initial submission leaves another race.
Do not generate release order from arbitrary lexical comparison of commit hashes. A hash identifies content, not chronological priority. Branch ancestry can establish a partial relationship, but an explicit rollback may intentionally select an older commit. Release intent needs an authorized action that can represent that decision.
Reconcile canceled work and intentional rollback
In a second synthetic schedule, a job submits deployment operation X, then its runner is canceled before receiving the response. The remote service may still complete X. Starting another deployment immediately treats an unknown outcome as a known failure and can create competing work outside the CI guard.
Query the operation identity through the deployment authority and reconcile active state. If the outcome remains unknown, preserve that state and follow a bounded recovery procedure. A failed runner is evidence about the runner, not definitive evidence that no remote mutation occurred.
An intentional rollback should create new authorized release intent, such as generation 14 selecting a previously verified artifact. It should not require turning off freshness checks or pretending that the older artifact belongs to the current build sequence. Retain compatibility checks because restoring bytes does not restore an earlier database or external side effect.
Test the protocol with reversed build completion, rejected stale admission, desired-generation changes during preparation, duplicate submission, and cancellation after remote acceptance. Assert the active artifact and operation record after each case. A parsed workflow file cannot substitute for these integration checks; they remain necessary before adopting the design in a real deployment system.
Assign an owner to recheck provider concurrency policies when the workflow changes. Keep two distinct observations in each deployment record: the guard that serialized participating work and the authoritative decision that allowed this artifact to become current. Together they explain why a late job could not silently undo a newer release.
Was this guide useful?
Your rating helps us prioritize clearer, more practical technical content.
Review diffs, run checks, and prepare the release in Arezgit.
Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.
Explore Arezgit