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 :
@@ -28,35 +33,34 @@ jobs:
2833
2934 - name : Set environment variables
3035 run : |
31- echo "ORG_BASE_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
3236 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
37+ echo "Current TOOLS_JAVA_VERSION: $TOOLS_JAVA_VERSION"
3738
3839 - name : Set up Docker Buildx
39- uses : docker/setup-buildx-action@v2
40+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
4041
4142 - name : Login to GitHub Container Registry
42- uses : docker/login-action@v2
43+ uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
4344 with :
4445 registry : ${{ env.REGISTRY }}
4546 username : ${{ github.actor }}
4647 password : ${{ secrets.GITHUB_TOKEN }}
4748
4849 - name : Extract components metadata
4950 id : meta_base
50- uses : docker/metadata-action@v4
51+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v51.0.0
5152 with :
52- images : |
53- ${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/tools-java
53+ tags : |
54+ type=ref,event=tag
55+ type=semver,pattern={{version}}
56+ type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
57+ labels : org.opencontainers.image.licenses=Apache-2.0
5458
5559 - name : Build Container
56- uses : docker/build-push-action@v3
60+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
5761 with :
5862 context : .
59- push : true
63+ push : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
6064 load : false
6165 build-args : |
6266 TOOLS_JAVA_VERSION=${{ env.TOOLS_JAVA_VERSION }}
0 commit comments