Skip to content

Commit 8942be9

Browse files
committed
Build latest on every master push, add untagged version cleanup
1 parent 87147e4 commit 8942be9

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Build and Publish Docker Image
22

33
on:
44
push:
5+
branches:
6+
- master
57
tags:
68
- 'v*'
79
workflow_dispatch:
@@ -45,10 +47,11 @@ jobs:
4547
with:
4648
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4749
tags: |
48-
# For tag pushes: v1.0.0 → 1.0.0 + latest
50+
# master push or version tag → latest
51+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
52+
# v1.2.3 tag push → 1.2.3 (also gets latest from above via ref)
4953
type=semver,pattern={{version}}
50-
type=raw,value=latest,enable=${{ github.event_name == 'push' }}
51-
# For manual dispatch: use the input tag
54+
# manual dispatch → use the input tag
5255
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
5356
5457
- name: Build and push
@@ -61,3 +64,18 @@ jobs:
6164
labels: ${{ steps.meta.outputs.labels }}
6265
cache-from: type=gha
6366
cache-to: type=gha,mode=max
67+
68+
cleanup:
69+
runs-on: ubuntu-latest
70+
needs: build-and-push
71+
permissions:
72+
packages: write
73+
74+
steps:
75+
- name: Delete old untagged package versions
76+
uses: actions/delete-package-versions@v5
77+
with:
78+
package-name: knock-knock
79+
package-type: container
80+
delete-only-untagged-versions: true
81+
min-versions-to-keep: 5

0 commit comments

Comments
 (0)