docker / metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
https://github.com/marketplace/actions/docker-metadata-action
Apache License 2.0
892 stars 115 forks source link

Commit SHA in pull request event is incorrect. #414

Closed iwata closed 3 months ago

iwata commented 3 months ago

Contributing guidelines

I've found a bug, and:

Description

I'm using type=ref,event=pr,suffix=-{{sha}} as tags option. But sha is incorrect.

Expected behaviour

sha returns github.event.pull_request.head.sha.

Actual behaviour

sha returns github.sha.

Repository URL

No response

Workflow run URL

No response

YAML workflow

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
        with:
          images: app
          tags: |
            type=ref,event=pr,suffix=-{{sha}}
      - name: debug
        run: |
          echo ${{ steps.meta.outputs.tags }}
          git rev-parse --short ${{ github.event.pull_request.head.sha }}
          git rev-parse --short "$GITHUB_SHA"

Workflow logs

pr-xxxx-937f26e
f03bb03
937f26e

BuildKit logs

No response

Additional info

No response

crazy-max commented 3 months ago

You need to set DOCKER_METADATA_PR_HEAD_SHA: true env var: https://github.com/docker/metadata-action?tab=readme-ov-file#environment-variables