Skip to content

Commit b6b846f

Browse files
committed
updated image labels
1 parent c74095f commit b6b846f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

.github/workflows/docker-image.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ jobs:
3131
username: ${{ secrets.DOCKERHUB_USERNAME }}
3232
password: ${{ secrets.DOCKERHUB_TOKEN }}
3333

34-
- name: Docker metadata
35-
id: meta
36-
uses: docker/metadata-action@v5
37-
with:
38-
images: ${{ env.REGISTRY_IMAGE }}
39-
tags: |
40-
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
41-
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
34+
- name: Prepare image tags
35+
id: prep
36+
run: |
37+
if [[ "${GITHUB_REF}" != refs/tags/v* ]]; then
38+
echo "This workflow must be triggered from a tag named like v1.2.3" >&2
39+
exit 1
40+
fi
41+
VERSION="${GITHUB_REF_NAME#v}"
42+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4243
4344
- name: Build and push
4445
uses: docker/build-push-action@v6
@@ -47,5 +48,10 @@ jobs:
4748
file: ./docker/Dockerfile-demo
4849
platforms: linux/amd64,linux/arm64
4950
push: true
50-
tags: ${{ steps.meta.outputs.tags }}
51-
labels: ${{ steps.meta.outputs.labels }}
51+
tags: |
52+
${{ env.REGISTRY_IMAGE }}:${{ steps.prep.outputs.version }}
53+
${{ env.REGISTRY_IMAGE }}:latest
54+
labels: |
55+
org.opencontainers.image.source=${{ github.repository }}
56+
org.opencontainers.image.revision=${{ github.sha }}
57+
org.opencontainers.image.version=${{ steps.prep.outputs.version }}

0 commit comments

Comments
 (0)