fix: skip Docker push when image tag already exists in immutable registry#1653
Merged
Conversation
The pr-envs.yml build job was failing with: "cannot update tag ... The repository has enabled tag immutability" Root cause: the workflow is triggered on labeled, synchronize, and opened PR events. When a label (e.g. 'deploy') is added to a PR without a new commit, the same full commit SHA is reused as the Docker tag, but the registry's immutability policy rejects overwriting it. Fix: - Extract the registry image URL to a job-level REGISTRY_IMAGE env var to remove duplication across the metadata and check steps. - Add a "Check if image already exists" step using `gcloud artifacts docker images describe` (already authenticated at that point). Error output is left visible for diagnosability. - Guard the "Build and push" step with `if: steps.image-check.outputs.exists != 'true'` so re-runs on the same commit SHA are idempotent and skip the push instead of failing.
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job build
fix: skip Docker push when image tag already exists in immutable registry
Jul 10, 2026
jeslefcourt
marked this pull request as ready for review
July 13, 2026 18:31
chrisj-er
approved these changes
Jul 17, 2026
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 does this PR do?
The
buildjob inpr-envs.ymlwas failing because the workflow triggers onlabeled,synchronize, andopenedevents. Adding a label to an existing PR (without a new commit) re-runs the workflow with the same commit SHA as the Docker tag — which the Google Artifact Registry rejects due to tag immutability.REGISTRY_IMAGEenv var extracted to job level, removing the duplicated registry URL acrossDocker metadataand the new check stepgcloud artifacts docker images describe(auth already established at that point); error output is intentionally left visible for diagnosabilityBuild and pushstep gated withif: steps.image-check.outputs.exists != 'true'— makes the job idempotent on re-runs; downstreamsyncandsummaryjobs are unaffected since a skipped step still yields asuccessjob resultEvidence
Error from the failing run:
Relevant link(s)
Notes