docker / docker/metadata-action
Expose pull request head ref as `{{branch}}` variable
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 160
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 12
Description
Description
When using {{branch}} variable in a pull_request event the output is '' (as documented).
It would be super useful to have it populated with github.event.pull_request.head.ref to compose tags like the following:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
tags: |
type=sha,format=short,prefix={{branch}}-
At the moment I'm doing something like:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
tags: |
type=sha,format=short,prefix=${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || '{{branch}}' }}-
But it seems a hack to me, is there any drawback in doing that?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the {{branch}} variable handling for pull_request events and compare its documented empty output with github.event.pull_request.head.ref. Verify the supplied metadata-action workflow example; done means the variable produces the pull request head ref so it can form the requested tag prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, github-actions
- Domain
- ci-cd, devops
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100