@@ -4,7 +4,7 @@ name: CI (Build & Push Docker)
44on :
55 push :
66 branches : [ "main" ]
7- tags : [ "v*.*.*" ]
7+ tags : [ "v*.*.*" ] # allow v2.0.1 or 2.0.1 (keep only the one you use)
88 workflow_dispatch : {}
99
1010env :
1313 DOCKERFILE : ./Dockerfile
1414
1515permissions :
16- contents : read # no write permissions needed
16+ contents : read
1717
1818jobs :
1919 build-and-push :
@@ -44,16 +44,25 @@ jobs:
4444 uses : docker/metadata-action@v5
4545 with :
4646 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+ # Only SemVer on tag events; only latest/branch/sha on branch events
4748 tags : |
48- type=sha
49- type=ref,event= branch
50- type=raw,value=latest ,enable={{is_default_branch }}
51- type=semver,pattern={{version }}
49+ type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
50+ type=raw,value=latest,enable=${{ github.ref_type == ' branch' && github.ref_name == 'main' }}
51+ type=ref,event=branch ,enable=${{ github.ref_type == 'branch' }}
52+ type=sha,enable=${{ github.ref_type == 'branch' }}
5253 labels : |
5354 org.opencontainers.image.title=${{ github.event.repository.name }}
5455 org.opencontainers.image.source=${{ github.repository }}
5556 org.opencontainers.image.revision=${{ github.sha }}
5657
58+ - name : Debug tags & labels
59+ run : |
60+ echo "TAGS:"
61+ echo "${{ steps.meta.outputs.tags }}"
62+ echo
63+ echo "LABELS:"
64+ echo "${{ steps.meta.outputs.labels }}"
65+
5766 - name : Build & Push (linux/amd64 + linux/arm64)
5867 uses : docker/build-push-action@v6
5968 with :
0 commit comments