Skip to content

Commit d3037bb

Browse files
committed
Fix build on PR
1 parent ae0b858 commit d3037bb

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/build-image.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,25 @@ jobs:
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+
labels: ${{ steps.meta.outputs.labels }}
83+
outputs: type=docker,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}
84+
build-args: |
85+
${{ inputs.build-args }}
86+
BASE=${{ inputs.base }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
- name: Build and push by digest
90+
if: github.event_name != 'pull_request'
91+
id: build-and-push
92+
uses: docker/build-push-action@v5
7793
with:
7894
context: ${{ inputs.context }}
7995
platforms: ${{ inputs.platform }}
@@ -87,16 +103,18 @@ jobs:
87103
cache-from: type=gha
88104
cache-to: type=gha,mode=max
89105
- name: Export digest
106+
if: github.event_name != 'pull_request'
90107
run: |
91108
mkdir -p /tmp/digests
92-
digest="${{ steps.build.outputs.digest }}"
109+
digest="${{ steps.build-and-push.outputs.digest }}"
93110
touch "/tmp/digests/${digest#sha256:}"
94111
- name: Set platform name
95112
id: platform
96113
run: |
97114
SAFE_PLATFORM=$(echo "${{ inputs.platform }}" | sed 's|/|-|g')
98115
echo "name=$SAFE_PLATFORM" >> $GITHUB_OUTPUT
99116
- name: Upload digest
117+
if: github.event_name != 'pull_request'
100118
uses: actions/upload-artifact@v4
101119
with:
102120
name: ${{ inputs.digest-prefix }}${{ steps.platform.outputs.name }}

0 commit comments

Comments
 (0)