revision is wrong (push to open PR)
dimaqq opened this issue · 7 comments
First of all, pardon me if this is a known GitHub Actions issue...
My action code:
echo "try 2 version:"
cat << EOF
${{ steps.tag.outputs.version }}
EOF
echo "try 2 tags:"
cat << EOF
${{ steps.tag.outputs.tags }}
EOF
echo "try 2 labels:"
cat << EOF
${{ steps.tag.outputs.labels }}
EOF
echo "try 2 json:"
jq . << EOF
${{ steps.tag.outputs.json }}
EOF
echo
echo "github event"
jq . $GITHUB_EVENT_PATH
where tag
is docker/medata-action@v4
When I push another commit to a branch with an open PR, I get this output:
try 2 version:
pr-10 # OK!
try 2 tags:
my/image:pr-10 # OK!
try 2 labels:
...
org.opencontainers.image.version=pr-10 # OK!
org.opencontainers.image.created=2023-04-06T02:30:38.641Z
org.opencontainers.image.revision=801fef0830758d8ccefdc8966569227b8bc22853 # ???
org.opencontainers.image.licenses=
try 2 json:
{
"tags": [
"my/image:pr-10"
],
"labels": {
...
"org.opencontainers.image.version": "pr-10",
"org.opencontainers.image.created": "2023-04-06T02:30:38.641Z",
"org.opencontainers.image.revision": "801fef0830758d8ccefdc8966569227b8bc22853", # ???
"org.opencontainers.image.licenses": ""
}
}
github event
{
"action": "synchronize",
"after": "d7a982e8f5b039c7e4607f87a826f74c53918aec", # correct!
"before": "5dc80b95cd193b52101c1eecb83961bf16139966",
"number": 10,
"organization": {
...
Where did the 801fef0...
hash come from?
It's not in the github event at all.
Meanwhile, my local checkout has my git commit d7a982...
on top, in line with github event.
And there's no commit like 801...
in my history.
At the same time, if I push a tag, the revision
is correct, it's the git hash that the tag points to.
@dimaqq Can you post your workflow please? Even better if you have a link to your repo.
There you go:
https://github.com/dimaqq/mre-metadata-action-283 repo
dimaqq/mre-metadata-action-283#1 sample PR
Here are all the git commits in the repo, all branches:
> gt
* 3fe33e0 (HEAD -> branch-1, origin/branch-1) a sample change
* 93d6762 (origin/main, origin/HEAD, main) CI debug for https://github.com/docker/metadata-action/issues/283
* c650ac7 Initial commit
Here's the GHA run: https://github.com/dimaqq/mre-metadata-action-283/actions/runs/4718439641/jobs/8368042252
Extract:
2023-04-17T07:09:03.1641463Z ##[group]JSON output
2023-04-17T07:09:03.1641740Z {
2023-04-17T07:09:03.1642057Z "tags": [
2023-04-17T07:09:03.1642593Z "quay.io/somerepo/someimage:pr-1"
2023-04-17T07:09:03.1642904Z ],
2023-04-17T07:09:03.1643199Z "labels": {
2023-04-17T07:09:03.1643746Z "org.opencontainers.image.title": "mre-metadata-action-283",
2023-04-17T07:09:03.1644437Z "org.opencontainers.image.description": "https://github.com/docker/metadata-action/issues/283",
2023-04-17T07:09:03.1645873Z "org.opencontainers.image.url": "https://github.com/dimaqq/mre-metadata-action-283",
2023-04-17T07:09:03.1646669Z "org.opencontainers.image.source": "https://github.com/dimaqq/mre-metadata-action-283",
2023-04-17T07:09:03.1647318Z "org.opencontainers.image.version": "pr-1",
2023-04-17T07:09:03.1647868Z "org.opencontainers.image.created": "2023-04-17T07:09:03.153Z",
2023-04-17T07:09:03.1648589Z "org.opencontainers.image.revision": "5d733763d2c575d9ac25b5c0922cbc1ac828df8f",
2023-04-17T07:09:03.1649174Z "org.opencontainers.image.licenses": "MIT"
2023-04-17T07:09:03.1649496Z }
2023-04-17T07:09:03.1649777Z }
The image.revision
git hash 5d73376
does not exist in my repo.
(my guess is that this is GitHub's magical "this would be the merge commit if the PR was merged" hash)
(my guess is that this is GitHub's magical "this would be the merge commit if the PR was merged" hash)
Yes this looks similar to #206. You need to set the associated head sha on pull request event by setting the DOCKER_METADATA_PR_HEAD_SHA
env var:
- id: tag
uses: docker/metadata-action@v4
with:
images:
quay.io/somerepo/someimage
env:
DOCKER_METADATA_PR_HEAD_SHA: true
Yep, looks the same.
I wish that PR_HEAD_SHA was on by default.
Yep, looks the same. I wish that PR_HEAD_SHA was on by default.
Just stumbled upon this PR and thought the same to myself until I saw #239
omg, this should be default