8
8
push :
9
9
branches :
10
10
- master
11
+
11
12
jobs :
13
+ check_commit :
14
+ runs-on : ubuntu-latest
15
+ outputs :
16
+ should_run : ${{ steps.check_commit_message.outputs.should_run }}
17
+ steps :
18
+ - name : Checkout code
19
+ uses : actions/checkout@v3
20
+ with :
21
+ fetch-depth : 2
22
+
23
+ - name : Check commit message
24
+ id : check_commit_message
25
+ run : |
26
+ COMMIT_MSG=$(git log -1 --pretty=%s)
27
+ if [[ "$COMMIT_MSG" == chore* ]]; then
28
+ echo "should_run=false" >> $GITHUB_OUTPUT
29
+ echo "Skipping workflow for commit: $COMMIT_MSG"
30
+ else
31
+ echo "should_run=true" >> $GITHUB_OUTPUT
32
+ echo "Running workflow for commit: $COMMIT_MSG"
33
+ fi
34
+
12
35
docker :
36
+ needs : check_commit
37
+ if : ${{ needs.check_commit.outputs.should_run == 'true' }}
13
38
runs-on : ubuntu-latest
14
39
steps :
15
40
- name : Checkout
@@ -33,11 +58,22 @@ jobs:
33
58
username : ${{ github.repository_owner }}
34
59
password : ${{ secrets.GITHUB_TOKEN }}
35
60
36
- - name : Build and push
37
- uses : docker/build-push-action@v5
61
+ - name : Extract metadata (tags, labels) for Docker
62
+ id : meta
63
+ uses : docker/metadata-action@v5
64
+ with :
65
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
66
+ flavor : |
67
+ latest=false
68
+ tags : |
69
+ type=raw,value=latest
70
+
71
+ - name : Build and push Docker image
72
+ uses : docker/build-push-action@v6
73
+ id : push
38
74
with :
39
75
context : .
40
- platforms : ${{ steps.buildx.outputs.platforms }}
41
76
push : true
42
- tags : |
43
- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
77
+ platforms : ${{ steps.buildx.outputs.platforms }}
78
+ tags : ${{ steps.meta.outputs.tags }}
79
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments