7171 registry : ${{ inputs.registry }}
7272 username : ${{ github.actor }}
7373 password : ${{ secrets.GITHUB_TOKEN }}
74- - name : Build and push by digest
74+ - name : Build
75+ if : github.event_name == 'pull_request'
7576 id : build
7677 uses : docker/build-push-action@v5
78+ with :
79+ context : ${{ inputs.context }}
80+ platforms : ${{ inputs.platform }}
81+ file : ${{ inputs.dockerfile }}
82+ push : false
83+ labels : ${{ steps.meta.outputs.labels }}
84+ outputs : type=image,name=${{ inputs.registry }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}
85+ build-args : |
86+ ${{ inputs.build-args }}
87+ BASE=${{ inputs.base }}
88+ cache-from : type=gha
89+ cache-to : type=gha,mode=max
90+ - name : Build and push by digest
91+ if : github.event_name != 'pull_request'
92+ id : build-and-push
93+ uses : docker/build-push-action@v5
7794 with :
7895 context : ${{ inputs.context }}
7996 platforms : ${{ inputs.platform }}
@@ -87,16 +104,18 @@ jobs:
87104 cache-from : type=gha
88105 cache-to : type=gha,mode=max
89106 - name : Export digest
107+ if : github.event_name != 'pull_request'
90108 run : |
91109 mkdir -p /tmp/digests
92- digest="${{ steps.build.outputs.digest }}"
110+ digest="${{ steps.build-and-push .outputs.digest }}"
93111 touch "/tmp/digests/${digest#sha256:}"
94112 - name : Set platform name
95113 id : platform
96114 run : |
97115 SAFE_PLATFORM=$(echo "${{ inputs.platform }}" | sed 's|/|-|g')
98116 echo "name=$SAFE_PLATFORM" >> $GITHUB_OUTPUT
99117 - name : Upload digest
118+ if : github.event_name != 'pull_request'
100119 uses : actions/upload-artifact@v4
101120 with :
102121 name : ${{ inputs.digest-prefix }}${{ steps.platform.outputs.name }}
0 commit comments