Skip to content

Commit 547943f

Browse files
committed
github action: modernize; auto-delete old pkgs
1 parent f76a01a commit 547943f

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

Diff for: .github/workflows/docker-image.yml

+32-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,47 @@ on:
55
tags:
66
- 'v*'
77

8-
env:
9-
GHP_TAG: "docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }}:${{ github.ref_name }}"
10-
118
jobs:
129
main:
1310
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
env:
17+
GHP_TAG: "ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}:${{ github.ref_name }}"
18+
package_name: "${{ github.event.repository.name }}/${{ github.event.repository.name }}"
19+
1420
steps:
1521
- name: Checkout
16-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
1723

1824
- name: Build docker image
1925
run: docker build --tag "$GHP_TAG" .
2026

21-
- name: Login to Github Packages
22-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin
27+
- name: Login to GitHub Packages
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
2333

2434
- name: Publish image to GitHub Packages
2535
run: docker push "$GHP_TAG"
36+
37+
- name: Delete all untagged packages
38+
uses: actions/delete-package-versions@v5
39+
with:
40+
package-name: "${{ env.package_name }}"
41+
package-type: container
42+
min-versions-to-keep: 0
43+
delete-only-untagged-versions: true
44+
45+
- name: Delete all but 10 newest packages
46+
uses: actions/delete-package-versions@v5
47+
with:
48+
package-name: "${{ env.package_name }}"
49+
package-type: container
50+
min-versions-to-keep: 10
51+

0 commit comments

Comments
 (0)