Skip to content

Conversation

@octo-sts
Copy link
Contributor

@octo-sts octo-sts bot commented May 29, 2025

Signed-off-by: wolfi-bot <121097084+wolfi-bot@users.noreply.github.com>
@octo-sts octo-sts bot added request-version-update request for a newer version of a package automated pr apko P1 This label indicates our scanning found High, Medium or Low CVEs for these packages. labels May 29, 2025
@octo-sts
Copy link
Contributor Author

octo-sts bot commented May 29, 2025

🔄 Build Failed: Git Checkout Error

fatal: Remote branch v0.27.8 not found in upstream origin

Build Details

Category Details
Build System git
Failure Point git clone --quiet --origin=origin --config=user.name=Melange Build --config=user.email=melange-build@cgr.dev --config=advice.detachedHead=false --branch=v0.27.8 --depth=1 https://github.com/chainguard-dev/apko /tmp/tmp.XOehTk

Root Cause Analysis 🔍

The build failed because it was trying to check out branch 'v0.27.8' from the apko repository, but that specific branch doesn't exist in the upstream repository. This is likely because v0.27.8 is a tag, not a branch, and the git checkout command incorrectly specified it as a branch parameter rather than a tag parameter.


🔍 Build failure fix suggestions

Found similar build failures that have been fixed in the past and analyzed them to suggest a fix:

Similar PRs with fixes

Suggested Changes

File: apko.yaml

  • replace at line 14-18 (pipeline section, git-checkout block)
    Original:
  - uses: git-checkout
    with:
      repository: https://github.com/chainguard-dev/apko
      tag: v${{package.version}}
      expected-commit: 914a57446266dc29e612ebbc2669c1045625880d

Replacement:

  - uses: git-checkout
    with:
      repository: https://github.com/chainguard-dev/apko
      branch: main
      tag: v${{package.version}}
      expected-commit: 914a57446266dc29e612ebbc2669c1045625880d
Click to expand fix analysis

Analysis

The pattern across both similar fixed build failures reveals a common issue: using the --branch parameter with git-checkout when the target is actually a tag, not a branch. In both examples, the error was similar: "fatal: Remote branch vX.X.X not found in upstream origin" which indicates that git was looking for a branch that didn't exist because it was trying to use a tag as a branch name. The fixes involved modifying the YAML configuration to properly handle tags instead of branches. Looking at the current failure with the apko package, we're seeing the exact same pattern where the build system is trying to check out "v0.27.8" as a branch when it should be treating it as a tag.

Click to expand fix explanation

Explanation

The current error occurs because the build system is attempting to use the tag "v0.27.8" as a branch name, which doesn't exist in the repository. The git-checkout action in Melange is attempting to perform a clone with --branch=v0.27.8, but v0.27.8 is a tag, not a branch.

By adding the branch: main parameter to the git-checkout action, we're instructing the system to first clone the main branch, and then checkout the specified tag. This matches the pattern seen in the successful fixes in the examples provided. The system will first clone the main branch and then checkout the specific tag v0.27.8.

The underlying issue is that git requires a different approach when checking out tags versus branches. When using --branch with a tag name, git fails because it's looking for a remote branch with that name. By specifying a valid branch first and then providing the tag, we ensure that git can properly find and checkout the tagged commit.

This change maintains the core functionality (checking out the v0.27.8 tag of the apko repository) while fixing the command syntax issue that's causing the build failure.

Click to expand alternative approaches

Alternative Approaches

  • Modify the Melange tool's git-checkout action to handle tags differently than branches and automatically use the correct git command parameters
  • Specify a reference rather than a tag in the YAML file: reference: refs/tags/v${{package.version}}
  • Change the git-checkout action to use a different clone method that doesn't require a branch parameter when checking out tags

Was this comment helpful? Please use 👍 or 👎 reactions on this comment.

@octo-sts octo-sts bot added the ai/skip-comment Stop AI from commenting on PR label May 29, 2025
@AmberArcadia
Copy link
Member

Looks like we had an oops with tagging the most recent release, I'll see about getting that fixed.
https://github.com/chainguard-dev/apko/tags

@AmberArcadia AmberArcadia self-assigned this May 29, 2025
@octo-sts octo-sts bot closed this May 30, 2025
@octo-sts
Copy link
Contributor Author

octo-sts bot commented May 30, 2025

superseded by #54766

@octo-sts octo-sts bot deleted the wolfictl-b12abfd1-f5ad-453b-8e93-ae5068ff7de0 branch May 31, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/skip-comment Stop AI from commenting on PR apko automated pr P1 This label indicates our scanning found High, Medium or Low CVEs for these packages. request-version-update request for a newer version of a package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants