ci: avoid duplicate Docker builds when a labeled PR is merged - #6
Merged
Merged
Conversation
Two changes prevent the pre-merge validation build from overlapping with the post-merge publish build: - release-candidate.yml gets a per-PR concurrency group with cancel-in-progress, so pushing new commits to a labeled PR cancels the previous (now-stale) validation build instead of stacking builds. - version-bump.yml, as its first step, cancels any release-candidate validation run still in flight for the merged PR's branch. When a labeled PR is merged immediately, the validation build is redundant — the release.yml run dispatched at the end of version-bump.yml validates and publishes the real (version-bumped, multi-arch) image anyway. Not reusing the PR-built image as the release is deliberate: the release image is built from the chore(release) commit (bumped package.json, so a different baked-in APP_VERSION) and is multi-arch, whereas the validation build is single-arch and pre-bump — the artifacts are not interchangeable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ST7p7inT3agkLEp8qbPSC6
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.
Summary
When a PR carries the
release-candidatelabel,release-candidate.ymlbuilds the Docker image (validation only, no push). If you then merge that PR immediately — while the validation build is still running — the post-merge pipeline (version-bump.yml→release.yml) builds the image again, so two Docker builds run at once. This dedupes that.Two changes:
release-candidate.ymlgets a per-PRconcurrencygroup withcancel-in-progress: true, so pushing new commits to a labeled PR cancels the previous (now-stale) validation build instead of stacking builds.version-bump.ymlcancels, as its very first step, anyrelease-candidate.ymlrun still in flight for the merged PR's branch. Once the PR is merged, that validation build is redundant: therelease.ymlrun dispatched at the end ofversion-bump.ymlvalidates and publishes the real image anyway.Why not "reuse the PR-built image instead of rebuilding after merge"?
This was the other option considered, but the PR-built image and the release image are not interchangeable:
chore(release): vX.Y.Zcommit, which has the bumpedpackage.json.APP_VERSION(shown in the app's sidebar footer) is baked in frompackage.jsonat build time — so the PR-built image would report the old version.So the PR build can't stand in for the release. Cancelling the redundant validation (rather than reusing it) is the fix that fits the current "bump the version after merge" flow.
Note on the two post-merge
release.ymlrunsMerging still produces two
release.ymlruns —:main/:edgefrom the merge commit, and the semver tags (:X.Y.Z,:latest) from the dispatched tag build. These are intentional (edge tracks main, latest tracks the release) and both usecache-to/from: type=gha, so the second run is mostly cache hits rather than a full second build. Left as-is; happy to collapse them too if you'd prefer only the semver build on a release merge.Test plan
version-bump.yml's first step cancels it, and only the post-mergerelease.ymlruns build/publish the image.Generated by Claude Code