Skip to content

Commit 508165e

Browse files
authored
Generate docker images for tagged commits (#73)
1 parent c4974cc commit 508165e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.github/workflows/build-image.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,17 @@ jobs:
3535
with:
3636
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
3737
tags: |
38-
# for commits on the main branch only, we will generate the tag named `latest`
38+
# (for commits on the main branch only) generate a tag named `latest`
3939
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
40-
# the tag named sha-[short sha value] will be generated in all cases
40+
# (for all commits) generate a tag named sha-[short sha value]
4141
type=sha,enable=true
42+
# (for tagged commits only) generate a tag identical to the git tag string, including the leading v
43+
type=semver,pattern={{raw}},enable=${{startsWith(github.ref, 'refs/tags/v')}}
4244
- name: Build and push
4345
uses: docker/build-push-action@v6
4446
with:
4547
platforms: linux/amd64,linux/arm64
46-
push: ${{ github.ref == format('refs/heads/{0}', 'main') }}
48+
# we push only if the pipeline is run against the commits on main branch or a tag
49+
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
4750
tags: ${{ steps.meta.outputs.tags }}
4851
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)