-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action fails: Cannot find detached HEAD ref in "grafted, HEAD, tag: x.x.x" #362
Action fails: Cannot find detached HEAD ref in "grafted, HEAD, tag: x.x.x" #362
Comments
Looks related to docker/actions-toolkit#173, cc @neilime |
Looks like it occurs when doing a shallow clone (using the --depth option). I've made a fix to handle these case: docker/actions-toolkit#217 |
@Programie Should be fixed with latest metadata-action release. |
I just tested the new version and it is working again. Thanks for the fix. 👍 |
Hello, This issue might still be occuring in some cases, I tried v5.3.0 of the metadata action and if I set
The reason I'm trying to use The simplest configuration I used to trigger the issue is: - uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: ...
context: git
tags: |
type=semver,pattern={{version}}
type=sha,prefix= |
@achille-roussel I'm curious about which event trigger this case (in your workflow, |
It's a pull request event. |
@achille-roussel can you share the workflow run url if it's possible (or the yml if not) |
This is from a private repository so I can't share the file as-is, but I'm attaching an altered version of the whole workflow (with private details removed). This is the fixed version where I switched back to Setting name: build
on:
push:
tags:
- v*
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: <ARN>
aws-region: <REGION>
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
- run: echo "version=${VERSION:0:7}" >> $GITHUB_OUTPUT
env:
VERSION: ${{ github.event.pull_request.head.sha || github.sha }}
id: vars
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ steps.ecr.outputs.registry }}/<IMAGE>
tags: |
type=semver,pattern={{version}}
type=raw,value=${{ steps.vars.outputs.version }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
cache-from: type=registry,ref=${{ steps.ecr.outputs.registry }}/<IMAGE>
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64
push: true |
I'm also still experiencing this issue. on:
workflow_dispatch:
inputs:
sha:
description: 'Commit SHA'
type: string
required: true
push:
description: 'Push images'
type: boolean
required: true
jobs:
build:
name: Build Docker containers
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.sha }}
-
name: Docker metadata for PHP image
id: php_meta
uses: docker/metadata-action@v5
with:
context: git
images: ...
tags: |
type=raw,priority=100,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,priority=200,event=branch
type=sha,priority=300,format=long,prefix=,suffix=
flavor: |
latest=false
prefix=
suffix= As you can see is a We fixed with: -
name: Docker metadata for PHP image
id: php_meta
uses: docker/metadata-action@v5
with:
context: git
images: ...
tags: |
type=raw,priority=100,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,priority=200,event=branch
type=raw,priority=300,value=${{ github.event.inputs.sha }}
flavor: |
latest=false
prefix=
suffix= But maybe you can use our example to reproduce the issue. |
Contributing guidelines
I've found a bug, and:
Description
Since version v5.1.0, the action fails with the following error whenever a specific git tag is checked out in combination with using
context: git
:The issue does not exist with version v5.0.0 of the action. I also can't reproduce it when checking out the default branch or any other branch. It only seems to be broken for tags.
Expected behaviour
The action completes without any issues and provides the expected tags for the image.
Actual behaviour
The action fails with the following error message:
Repository URL
https://github.com/Programie/PHP-Docker
Workflow run URL
https://github.com/Programie/PHP-Docker/actions/runs/7073444694
YAML workflow
Workflow logs
BuildKit logs
Additional info
No response
The text was updated successfully, but these errors were encountered: