fix: guard RC docker job against empty vtag and add early validation in docker.yml#983
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add `&& needs.publish.outputs.vtag != ''` to the `docker` job's `if:` in release-candidate.yml so it is skipped when publish produces no vtag, preventing an opaque buildx "tag is needed" error. - Add an early "Validate tag input" step in docker.yml that fails fast with a clear ::error:: message when inputs.tag is empty, covering direct workflow_call invocations that bypass the release-candidate guard. Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b9afe2df-85ea-4a87-bf30-77f0e945a64d Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
|
@claude review this |
|
Claude finished @magyargergo's task in 1m 13s —— View job Code Review
SummaryThe fix correctly addresses the root cause:
|
@copilot look into this |
Direct tag-push triggers (on: push, tags: v*) populate the tag from GITHUB_REF and have inputs.tag empty, so the unconditional validation step would fail every direct tag-push run. Restrict the new step to workflow_call invocations, which is the only path where an empty tag is actually a problem. Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/4b7e3bfa-15c0-4186-affa-95cd71e50153 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
... Good catch — added |
…in docker.yml (abhigyanpatwari#983) * Initial plan * fix: guard docker job and add tag validation in docker.yml - Add `&& needs.publish.outputs.vtag != ''` to the `docker` job's `if:` in release-candidate.yml so it is skipped when publish produces no vtag, preventing an opaque buildx "tag is needed" error. - Add an early "Validate tag input" step in docker.yml that fails fast with a clear ::error:: message when inputs.tag is empty, covering direct workflow_call invocations that bypass the release-candidate guard. Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b9afe2df-85ea-4a87-bf30-77f0e945a64d Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> * fix: scope docker.yml tag validation to workflow_call only Direct tag-push triggers (on: push, tags: v*) populate the tag from GITHUB_REF and have inputs.tag empty, so the unconditional validation step would fail every direct tag-push run. Restrict the new step to workflow_call invocations, which is the only path where an empty tag is actually a problem. Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/4b7e3bfa-15c0-4186-affa-95cd71e50153 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
When the
publishjob in the RC workflow fails before theCreate and push rc tagsstep,needs.publish.outputs.vtagis empty. Thedockerjob still ran, callingdocker.ymlwith no tag, which caused buildx to error with the opaquetag is needed when pushing to registry.Changes
release-candidate.yml— tighten thedockerjob'sif:to skip entirely whenvtagis empty:docker.yml— add a fail-fast validation step as the first step in the build job, before any docker setup runs:This acts as a second line of defence for any direct
workflow_callinvocation that bypasses the RC guard.Original prompt
Background
The
Build & Push RC Docker imagesjob in theRelease Candidateworkflow failed with:Failing run: https://github.com/abhigyanpatwari/GitNexus/actions/runs/24623117763/job/71998787708
Workflow:
.github/workflows/release-candidate.ymlReusable workflow being called:
.github/workflows/docker.ymlRoot cause
The
dockerjob in.github/workflows/release-candidate.ymlcalls the reusabledocker.ymlworkflow and passestag: ${{ needs.publish.outputs.vtag }}.vtagis only set by theCreate and push rc tagsstep inside thepublishjob. If thepublishjob fails before that step runs (or the output is otherwise empty),docker.ymlis invoked with an emptytaginput.docker/build-push-actionthen runs withpush: truebut no tags, and buildx errors with "tag is needed when pushing to registry".Required changes
Please make the following changes:
1. Guard the
dockerjob in.github/workflows/release-candidate.ymlUpdate the
dockerjob'sif:condition to also require thatpublish.outputs.vtagis non-empty, so the job is skipped (rather than producing a confusing buildx error) when no rc tag was produced:2. Validate the
taginput inside.github/workflows/docker.ymlAdd an early validation step (before any docker build/push step) in
.github/workflows/docker.ymlthat fails fast with a clear error message when thetaginput is empty. Something like:Place it as the first step in any job that performs a
docker/build-push-actionwithpush: true, before the buildx/build step runs. This ensures the failure is loud and obvious instead of an opaque buildx error.Acceptance criteria
.github/workflows/release-candidate.yml'sdockerjob has anif:that includesneeds.publish.outputs.vtag != ''..github/workflows/docker.ymlfails fast with a clear::error::message when invoked with an emptytaginput.Out of scope
publishjob itself failed in run 24623117763 (tag/package.json version mismatch and cosign issues). That can be handled in a follow-up.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How can I fix this build?
Assistant: ## Why the build failed
The failing job is Build & Push RC Docker images (reusable workflow
docker.yml, called fromrelease-candidate.yml). Buildx errored with:This means the docker build step ran with
push: truebut notags:were resolved. Looking at the caller in.github/workflows/release-candidate.yml(lines 377–388):The
dockerjob onlyneeds: [guard, publish], but notci. Becauseciwas still running/queued (or finished afterpublishstarted), and more importantly becausepublish.outputs.vtagis only set by theCreate and push rc tagsstep insidepublish, the value passed todocker.ymlcame through empty for this run — sodocker/metadata-action(or thetags:input indocker.yml) produced no tag, and buildx refused to push.In the logs you can confirm
publishdid not actually emit avtagfor this run beforedockerconsumed it (the publish job's tag-creation step never ran successfully — note there's no rc tag commit in the output, only the buildx push failure).How to fix
Two things to do — pick one minimally, but I'd recommend both:
1. Guard the
dockerjob against an empty tagIn
.github/workflows/release-candidate.yml, tighten theif:so docker only runs when publish actually produced a vtag:This makes the failure mode loud and prevents calling
docker.ymlwith an empty tag.#...
This pull request was created from Copilot chat.