Closed chainhead closed 1 year ago
Linked to --tag 5783df2
. You're trying to push the image named 5783df2
which looks wrong. Related to this line in your workflow:
${{ github.ref_name }}-${{ steps.commit.outputs.short }}
Can you post the logs of the name: Extract metadata (tags, labels) for Docker
step please?
Also please post your full workflow. I don't know what is ${{ env.REGISTRY }}
.
I realised the mistake I made. I had two tags one of which didn't have a registry. This defaulted to docker.io
. My intention was to use the short commit hash as part of the tag and so, should have concatenated the ghcr.io/nsubrahm/alarms:v0.00
and the hash.
This worked.
- id: build-push-native-micro
name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./${{ env.DOCKERFILE_PATH }}/Dockerfile.${{ env.QUARKUS_MODE }}
push: true
tags: |
${{ steps.meta.outputs.tags }}-${{ steps.commit.outputs.short }}
labels: ${{ steps.meta.outputs.labels }}
Be careful, ${{ steps.meta.outputs.tags }
can be a multiline value. Please refer to the docs to know more about the tags
input in the metadata action.
So, when raising a PR against main
branch, the generated tag becomes latest-<commit_hash>
. This will not do.
Here is my requirement.
git push
against a non-main
branch, I want the image to be tagged as <branch_name>-<commit_hash>
.latest
.The following works for 1 above. However, for 2, the generated tag becomes latest-<commit_hash>
. How do I resolve this?
- id: meta
name: Extract metadata (tags, labels) for Docker
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
- id: build-push-native-micro
name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./${{ env.DOCKERFILE_PATH }}/Dockerfile.${{ env.QUARKUS_MODE }}
push: true
tags: |
${{ steps.meta.outputs.tags }}-${{ steps.commit.outputs.short }}
labels: ${{ steps.meta.outputs.labels }}
This is not related to the build-push action but the metadata action. Please open a discussion thread: https://github.com/docker/metadata-action/discussions
Troubleshooting
Before submitting a bug report please read the Troubleshooting doc.
Behaviour
I have a GH Action (see below) that is set-up to build and publish container image to
ghcr.io
. Theenv.REGISTRY
is set toghcr.io
. Going by the example here, the following YAML should work because the tagghcr.io/repo/project:tag
is automatically generated by themeta
step. However, rather than pushing to GHCR, the push is attempted for Docker Hub and fails.Steps to reproduce this issue
ghcr
as shown below.Expected behaviour
GH Action should push to
ghcr.io
Actual behaviour
GH Action pushes to Docker Hub and fails.
Configuration