|
5 | 5 | tags:
|
6 | 6 | - 'v*'
|
7 | 7 |
|
8 |
| -env: |
9 |
| - GHP_TAG: "docker.pkg.github.com/${{ github.repository }}/${{ github.event.repository.name }}:${{ github.ref_name }}" |
10 |
| - |
11 | 8 | jobs:
|
12 | 9 | main:
|
13 | 10 | 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 | + |
14 | 20 | steps:
|
15 | 21 | - name: Checkout
|
16 |
| - uses: actions/checkout@v3 |
| 22 | + uses: actions/checkout@v4 |
17 | 23 |
|
18 | 24 | - name: Build docker image
|
19 | 25 | run: docker build --tag "$GHP_TAG" .
|
20 | 26 |
|
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 }} |
23 | 33 |
|
24 | 34 | - name: Publish image to GitHub Packages
|
25 | 35 | 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