Skip to content

fix: skip Docker push when image tag already exists in immutable registry#1653

Merged
chrisj-er merged 2 commits into
developfrom
copilot/fix-github-actions-build-job
Jul 17, 2026
Merged

fix: skip Docker push when image tag already exists in immutable registry#1653
chrisj-er merged 2 commits into
developfrom
copilot/fix-github-actions-build-job

Conversation

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The build job in pr-envs.yml was failing because the workflow triggers on labeled, synchronize, and opened events. 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_IMAGE env var extracted to job level, removing the duplicated registry URL across Docker metadata and the new check step
  • Image existence check added using gcloud artifacts docker images describe (auth already established at that point); error output is intentionally left visible for diagnosability
  • Build and push step gated with if: steps.image-check.outputs.exists != 'true' — makes the job idempotent on re-runs; downstream sync and summary jobs are unaffected since a skipped step still yields a success job result

Evidence

Error from the failing run:

ERROR: failed to build: failed to solve: failed to push
europe-west3-docker.pkg.dev/.../das-web-react:e7841a20...:
unknown: cannot update tag e7841a20.... The repository has enabled tag immutability

Relevant link(s)

Notes

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
Copilot AI requested a review from jeslefcourt July 10, 2026 14:19
@jeslefcourt
jeslefcourt requested a review from luixlive July 11, 2026 00:36
@jeslefcourt
jeslefcourt marked this pull request as ready for review July 13, 2026 18:31
@chrisj-er
chrisj-er merged commit 6f3280c into develop Jul 17, 2026
4 checks passed
@chrisj-er
chrisj-er deleted the copilot/fix-github-actions-build-job branch July 17, 2026 15:19
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.

3 participants