[WIP] Fix invalid tag format in Docker build#8
Conversation
The issue was that the SHA tag rule `type=sha,prefix={{branch}}-` was generating invalid tags like `-9f8980e` when triggered on pull requests, because the {{branch}} variable is empty for PR events. This violates Docker's naming conventions which don't allow tags starting with a hyphen.
The fix restricts SHA tag generation to only run on the default branch by adding `enable={{is_default_branch}}`. For pull requests, the existing `type=ref,event=pr` rule already provides appropriate tags like `pr-6`.
Co-authored-by: xrh0905 <29017419+xrh0905@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix an invalid Docker tag format error that occurs during GitHub Actions workflow execution. The error invalid tag "ghcr.io/xrh0905/mtprotoproxy:-9f8980e" indicates that the {{branch}} placeholder in the metadata-action configuration is empty, causing tags to start with a hyphen.
Key Changes:
- Added
enable={{is_default_branch}}condition to thetype=shatag configuration to limit when SHA-based tags are generated
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| type=semver,pattern={{major}}.{{minor}} | ||
| type=semver,pattern={{major}} | ||
| type=sha,prefix={{branch}}- | ||
| type=sha,prefix={{branch}}-,enable={{is_default_branch}} |
There was a problem hiding this comment.
The enable={{is_default_branch}} condition may not fully prevent the invalid tag issue. The {{branch}} placeholder is empty for tag push events (matching v*.*.*), which would still generate tags like -9f8980e with a leading hyphen.
Consider using event=push instead to only generate this tag for branch pushes:
type=sha,prefix={{branch}}-,event=push,enable={{is_default_branch}}Alternatively, if you want SHA tags for all branch pushes (not just default branch), use:
type=sha,prefix={{branch}}-,event=push| type=sha,prefix={{branch}}-,enable={{is_default_branch}} | |
| type=sha,prefix={{branch}}-,event=push,enable={{is_default_branch}} |
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.