Skip to content

[WIP] Fix invalid tag format in Docker build#8

Merged
xrh0905 merged 2 commits into
edgefrom
copilot/fix-action-error
Dec 9, 2025
Merged

[WIP] Fix invalid tag format in Docker build#8
xrh0905 merged 2 commits into
edgefrom
copilot/fix-action-error

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 9, 2025

  • Analyze the GitHub Actions workflow file to understand the tag generation issue
  • Fix the invalid tag format by correcting the metadata-action configuration
  • Test the workflow configuration to ensure tags are generated correctly for different event types
  • Verify the fix resolves the CI/Build failure
  • Code review passed with no issues
  • Security scan passed with no vulnerabilities
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix Action error</issue_title>
<issue_description>WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
ERROR: failed to build: invalid tag "ghcr.io/xrh0905/mtprotoproxy:-9f8980e": invalid reference format
Error: buildx failed with: ERROR: failed to build: invalid tag "ghcr.io/xrh0905/mtprotoproxy:-9f8980e": invalid reference format</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

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>
@xrh0905 xrh0905 marked this pull request as ready for review December 9, 2025 15:52
Copilot AI review requested due to automatic review settings December 9, 2025 15:52
@xrh0905 xrh0905 merged commit 76e3887 into edge Dec 9, 2025
4 checks passed
Copilot AI requested a review from xrh0905 December 9, 2025 15:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the type=sha tag 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}}
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Suggested change
type=sha,prefix={{branch}}-,enable={{is_default_branch}}
type=sha,prefix={{branch}}-,event=push,enable={{is_default_branch}}

Copilot uses AI. Check for mistakes.
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.

Fix Action error

3 participants