ci: fix invalid Docker debug tag on PR builds - #4
Merged
Conversation
The metadata tag 'type=sha,prefix={{branch}}-...' resolves to an empty
branch for pull_request events, producing an invalid Docker tag like
'-0d4169b-debug-amd64' which fails docker/build-push-action. Use a fixed
'sha-' prefix so the tag is always valid and unique across events. The
branch-scoped and PR-scoped debug tags from 'type=ref' are unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Why
PR-triggered
Buildworkflow runs fail in the "Build Docker Image (linux/amd64)" and "(linux/arm64)" jobs. The failure is not related to any code change: it is a CI bug in.github/workflows/build.yml.The Docker metadata uses
type=sha,prefix={{branch}}-for the debug image tag. Onpull_requestevents, docker/metadata-action resolves{{branch}}to an empty string, so the generated tag becomes:Docker rejects tags that start with
-(invalid reference format), sodocker/build-push-actionfails. Onmain-push builds the branch context ismain, so the tag is valid (main-<sha>-debug-amd64) and those runs pass. This is why every PR build fails while everymainbuild succeeds.Approach
Replace the branch-dependent prefix
{{branch}}-with a fixedsha-prefix in both the amd64 and arm64 metadatatype=shatags:This always yields a valid, unique tag (
sha-<sha>-debug-amd64) regardless of event type. The branch-scoped and PR-scoped debug tags (type=ref,event=branch/type=ref,event=pr) are unchanged, so the multi-arch manifest job and release flow are unaffected.Verification
type=shatag definitions; tag strings are now event-independent and structurally valid.type=refandtype=rawtags, not thetype=shatag.