How to set org.opencontainers.image.version with git sha?
#586
-
|
I'm calling the action with: - name: Docker meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/devcontainer
labels: |
org.opencontainers.image.title=Devcontainer
org.opencontainers.image.description=A multi-purpose Docker on Docker or Docker in Docker image to be used as a Devcontainer.
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,enable=${{ github.event_name == 'push' }}
type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}And on org.opencontainers.image.version: masterWhich is pretty much useless. I would like the org.opencontainers.image.version: sha-ee426c9Any ideas to accomplish it? Maybe that should even be the default value when |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Quick answerImplicitly via Be explicit: # Image config stores labels:
labels: |
org.opencontainers.image.revision=sha-${{ github.sha }}
# Image index/manifest annotations are useful for queries/filters when interacting with a registry:
annotations: |
org.opencontainers.image.revision=sha-${{ github.sha }}Long answerThis is an easy mistake (I've made it myself), but it is actually explained in the docs (just easy to miss), it's due to the action assigning priority values to different In your case, Lines 808 to 810 in ed95091 You can always prioritize your If there's multiple tags with the same priority value, it will be the first one you defined of that priority (the sorting won't mess with your declaration order of same priority), if you would like more control over that or the default More details here if you need a technical deep-dive to understand implementation: #587 (comment) Alternatively, if you don't need that labels: |
org.opencontainers.image.revision=${{ github.sha }}or add the labels: |
org.opencontainers.image.revision=sha-${{ github.sha }}Remember to do the same if you also use |
Beta Was this translation helpful? Give feedback.
-
Off-topic - Feedback / Questions on your other tag typesYour raw I'm not sure if you can use it within
I don't believe a tag event would be considered the default branch either (if you were to later add that). I'd be interested in understanding the value of the
Likewise, bit curious about
Any insights to how those tags are useful would be great for me to know 😁 |
Beta Was this translation helpful? Give feedback.
Quick answer
Implicitly via
tagsinput, setpriorityabove all defaults:Be explicit:
Long answer
This is an easy mistake (I've made it myself), but it is actually explained in the docs (just easy to miss), it's due to the action assigning priority values to different
types which will sort yourtagsby priority and the first tag processed (enabled) from tha…