11name : Prepare release
22
33on :
4- push :
5- branches :
6- - main
74 release :
85 types : [published]
96
@@ -16,70 +13,9 @@ permissions:
1613 packages : write
1714
1815jobs :
19- pre-check :
20- runs-on : ubuntu-22.04
21- outputs :
22- skip-workflow : ${{ steps.check.outputs.skip-workflow }}
23- steps :
24- - name : Check if workflow should be skipped
25- id : check
26- run : |
27- if [[ "${{ github.event.head_commit.author.name }}" == "github-actions[bot]" ]] && [[ "${{ github.event.head_commit.message }}" == Release\ version* ]]; then
28- echo "skip-workflow=true" >> $GITHUB_OUTPUT
29- echo "Skipping this workflow..."
30- else
31- echo "skip-workflow=false" >> $GITHUB_OUTPUT
32- echo "Proceeding with this workflow..."
33- fi
34-
35- build-and-push-image :
36- runs-on : ubuntu-22.04
37- needs : [pre-check]
38- if : ${{ !startsWith(github.ref, 'refs/tags/') && needs.pre-check.outputs.skip-workflow == 'false' }}
39- steps :
40- - name : Checkout repository
41- uses : actions/checkout@v4
42- with :
43- fetch-depth : 0
44-
45- - name : Set up Docker Buildx
46- uses : docker/setup-buildx-action@v3
47-
48- - name : Log in to Container Registry
49- uses : docker/login-action@v3
50- with :
51- registry : ${{ env.REGISTRY }}
52- username : ${{ github.actor }}
53- password : ${{ secrets.GITHUB_TOKEN }}
54-
55- - name : Extract metadata
56- id : meta
57- uses : docker/metadata-action@v5
58- with :
59- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60- tags : |
61- type=ref,event=branch
62- type=ref,event=pr
63- type=sha,prefix=sha-
64-
65- - name : Build and push Docker image
66- id : build-and-push
67- uses : docker/build-push-action@v5
68- with :
69- context : .
70- platforms : linux/amd64,linux/arm64
71- push : true
72- tags : ${{ steps.meta.outputs.tags }}
73- labels : ${{ steps.meta.outputs.labels }}
74- build-args : |
75- VERSION=${{ github.sha }}
76- cache-from : type=gha
77- cache-to : type=gha,mode=max
78-
7916 tag-release-image :
8017 runs-on : ubuntu-22.04
81- needs : [pre-check]
82- if : ${{ startsWith(github.event.release.tag_name, 'v') && needs.pre-check.outputs.skip-workflow == 'false' }}
18+ if : ${{ startsWith(github.event.release.tag_name, 'v') }}
8319 steps :
8420 - name : Log in to Container Registry
8521 uses : docker/login-action@v3
8824 username : ${{ github.actor }}
8925 password : ${{ secrets.GITHUB_TOKEN }}
9026
91- - name : Get latest SHA image
27+ - name : Get latest SHA image from the main branch
9228 id : get-sha
9329 run : |
9430 # Get the latest commit SHA from the main branch
@@ -196,5 +132,5 @@ jobs:
196132 token : ${{ secrets.GITHUB_TOKEN }}
197133 exclude-tags : ' ^v[0-9]+\.[0-9]+\.[0-9]+$'
198134 use-regex : true
199- keep-n-tagged : 20
135+ keep-n-tagged : 30
200136 log-level : info
0 commit comments