66name : Docker Build
77
88on :
9+ workflow_dispatch :
10+ pull_request :
11+ paths :
12+ - Dockerfile
13+ - .github/workflows/docker_deploy.yml
914 push :
1015 paths-ignore :
11- - " **.md"
16+ - ' **.md'
1217 tags :
1318 - ' v*'
1419env :
@@ -24,42 +29,34 @@ jobs:
2429
2530 steps :
2631 - name : Checkout main repository
27- uses : actions/checkout@v3
28-
29- - name : Set environment variables
30- run : |
31- echo "ORG_BASE_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
32- echo "TOOLS_JAVA_VERSION=${GITHUB_REF_NAME/v/}" >> $GITHUB_ENV
33- - name : Echoing current version
34- run : |
35- echo "$TOOLS_JAVA_VERSION"
36- echo $GITHUB_REF_NAME
32+ uses : actions/checkout@v5
3733
3834 - name : Set up Docker Buildx
39- uses : docker/setup-buildx-action@v2
35+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
4036
4137 - name : Login to GitHub Container Registry
42- uses : docker/login-action@v2
38+ uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
4339 with :
4440 registry : ${{ env.REGISTRY }}
4541 username : ${{ github.actor }}
4642 password : ${{ secrets.GITHUB_TOKEN }}
4743
4844 - name : Extract components metadata
4945 id : meta_base
50- uses : docker/metadata-action@v4
46+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v51.0.0
5147 with :
52- images : |
53- ${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/tools-java
48+ tags : |
49+ type=ref,event=tag
50+ type=semver,pattern={{version}}
51+ type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
52+ labels : org.opencontainers.image.licenses=Apache-2.0
5453
5554 - name : Build Container
56- uses : docker/build-push-action@v3
55+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
5756 with :
5857 context : .
59- push : true
58+ push : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
6059 load : false
61- build-args : |
62- TOOLS_JAVA_VERSION=${{ env.TOOLS_JAVA_VERSION }}
6360 tags : |
6461 ${{ steps.meta_base.outputs.tags }}
6562 labels : ${{ steps.meta_base.outputs.labels }}
0 commit comments