@@ -35,14 +35,20 @@ jobs:
3535 uses : docker/setup-qemu-action@v3
3636 - name : Set up Docker Buildx
3737 uses : docker/setup-buildx-action@v3
38- - name : Build Docker Image
39- id : build-image
38+ - name : Login to DockerHub
39+ if : github.event_name == 'workflow_call'
40+ uses : docker/login-action@v3
41+ with :
42+ username : ${{ secrets.DOCKERHUB_USERNAME }}
43+ password : ${{ secrets.DOCKERHUB_TOKEN }}
44+ - name : Build (and maybe push) Docker image
4045 uses : docker/build-push-action@v6
4146 with :
42- context : ${{ inputs.DOCKER_PATH_CONTEXT || env.DOCKER_PATH_CONTEXT }}
43- file : ${{ inputs.DOCKER_BUILD_DOCKERFILE || env.DOCKER_BUILD_DOCKERFILE }}
44- load : ${{ inputs.DOCKER_LOAD_BOOL || env.DOCKER_LOAD_BOOL }}
45- tags : ${{ inputs.DOCKER_TAGS || env.DOCKER_TAGS }}
47+ context : ${{ github.event_name == 'workflow_call' && inputs.DOCKER_PATH_CONTEXT || env.DOCKER_PATH_CONTEXT }}
48+ file : ${{ github.event_name == 'workflow_call' && inputs.DOCKER_BUILD_DOCKERFILE || env.DOCKER_BUILD_DOCKERFILE }}
49+ load : ${{ github.event_name != 'workflow_call' }}
50+ push : ${{ github.event_name == 'workflow_call' }}
51+ tags : ${{ github.event_name == 'workflow_call' && inputs.DOCKER_TAGS || env.DOCKER_TAGS }}
4652 - name : Run Trivy vulnerability scanner
4753 uses : aquasecurity/trivy-action@0.33.1
4854 with :
5258 ignore-unfixed : true
5359 vuln-type : ' os,library'
5460 severity : ' CRITICAL,HIGH'
55- - name : Login to DockerHub
56- if : github.event_name == 'workflow_call'
57- uses : docker/login-action@v3
58- with :
59- username : ${{ secrets.DOCKERHUB_USERNAME }}
60- password : ${{ secrets.DOCKERHUB_TOKEN }}
61- - name : Push Docker image to DockerHub
62- if : github.event_name == 'workflow_call'
63- uses : docker/build-push-action@v6
64- with :
65- context : ${{ inputs.DOCKER_PATH_CONTEXT || env.DOCKER_PATH_CONTEXT }}
66- file : ${{ inputs.DOCKER_BUILD_DOCKERFILE || env.DOCKER_BUILD_DOCKERFILE }}
67- push : true
68- tags : ${{ inputs.DOCKER_TAGS || env.DOCKER_TAGS }}
0 commit comments