@@ -2,10 +2,8 @@ name: Build and Push Docker Image
22
33on :
44 push :
5- branches :
6- - main
75 tags :
8- - ' v*.*.*' # Triggers on version tags like v1.0.0, v1.2.3, etc.
6+ - ' v*.*.*' # Only trigger on version tags like v1.0.0, v1.2.3, etc.
97 pull_request :
108 branches :
119 - main
3735 uses : docker/setup-buildx-action@v3
3836
3937 - name : Log in to DockerHub
40- if : github.event_name != 'pull_request'
38+ if : startsWith( github.ref, 'refs/tags/v')
4139 uses : docker/login-action@v3
4240 with :
4341 username : ${{ secrets.DOCKERHUB_USERNAME }}
@@ -69,15 +67,15 @@ jobs:
6967 uses : docker/build-push-action@v5
7068 with :
7169 context : .
72- push : ${{ github.event_name != 'pull_request' }}
70+ push : ${{ startsWith( github.ref, 'refs/tags/v') }}
7371 tags : ${{ steps.meta.outputs.tags }}
7472 labels : ${{ steps.meta.outputs.labels }}
7573 cache-from : type=gha
7674 cache-to : type=gha,mode=max
7775 platforms : linux/amd64
7876
7977 - name : Generate artifact attestation
80- if : github.event_name != 'pull_request'
78+ if : startsWith( github.ref, 'refs/tags/v')
8179 uses : actions/attest-build-provenance@v1
8280 with :
8381 subject-name : ${{ env.DOCKER_IMAGE }}
0 commit comments