Skip to content

fix: derive Docker image branch tags from workflow event context#268

Draft
toby-coleman with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-docker-build-issue
Draft

fix: derive Docker image branch tags from workflow event context#268
toby-coleman with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-docker-build-issue

Conversation

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The Docker publish workflow failed while exporting branch metadata because it derived GIT_BRANCH by listing merged remote branches and wrote a multiline value into GITHUB_ENV. This change makes branch/SHA resolution event-driven so Docker tagging works for push, workflow_run, and manual executions.

Changes

  • Workflow context resolution

    • Check out the triggering commit directly for workflow_run jobs instead of relying on github.ref.
    • Resolve branch and SHA from event payload fields with local git fallback only when needed.
  • Environment export hardening

    • Replace the remote-branch enumeration logic with a single branch value.
    • Write GIT_HASH_SHORT, GIT_BRANCH, and GIT_BRANCH_DOCKER_SAFE via printf to avoid malformed GITHUB_ENV entries.
  • Docker tag stability

    • Preserve the existing Docker metadata/tagging flow while ensuring the branch-derived tag is always a single safe value.
env:
  EVENT_BRANCH: ${{ github.event.workflow_run.head_branch || github.ref_name }}
  EVENT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
run: |
  git_hash_short=$(git rev-parse --short "$EVENT_SHA")
  printf 'GIT_HASH_SHORT=%s\n' "${git_hash_short}" >> "$GITHUB_ENV"
  git_branch="$EVENT_BRANCH"

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.

2 participants