Skip to content

Commit 22ce191

Browse files
authored
fix: stabilize docker build workflow for digest pushes (#20)
* fix: split build into local verify and push steps to avoid concurrent export conflict * fix: separate PR verify build from push-by-digest flow * fix: run verification with explicit matrix platform
1 parent e7e1698 commit 22ce191

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,44 @@ jobs:
9292
username: ${{ github.actor }}
9393
password: ${{ secrets.GITHUB_TOKEN }}
9494

95+
- name: Build local image for verification
96+
if: github.event_name == 'pull_request'
97+
id: build-pr
98+
uses: docker/build-push-action@v6
99+
with:
100+
context: .
101+
platforms: ${{ matrix.platform }}
102+
labels: ${{ steps.meta.outputs.labels }}
103+
load: true
104+
cache-from: type=gha,scope=build-${{ matrix.platform }}
105+
cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }}
106+
107+
- name: Verify language runtimes and packages
108+
if: github.event_name == 'pull_request'
109+
run: |
110+
# Run the verification script inside the container
111+
docker run --rm --platform ${{ matrix.platform }} -v $(pwd)/test/bin:/test/bin ${{ steps.build-pr.outputs.imageid }} bash -c "\
112+
/test/bin/verify-languages.sh; \
113+
/test/bin/verify-packages.sh; \
114+
"
115+
95116
- name: Build and push by digest
117+
if: github.event_name != 'pull_request'
96118
id: build
97119
uses: docker/build-push-action@v6
98120
with:
99121
context: .
100122
platforms: ${{ matrix.platform }}
101123
labels: ${{ steps.meta.outputs.labels }}
102-
outputs: |
103-
type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
104-
type=docker
124+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
105125
cache-from: type=gha,scope=build-${{ matrix.platform }}
106126
cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }}
107127

108128
- name: Verify language runtimes and packages
129+
if: github.event_name != 'pull_request'
109130
run: |
110-
# Run the verification script inside the container
111-
docker run --rm -v $(pwd)/test/bin:/test/bin ${{ steps.build.outputs.imageid }} bash -c "\
131+
# Run the verification script inside the pushed digest image
132+
docker run --rm --platform ${{ matrix.platform }} -v $(pwd)/test/bin:/test/bin ${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }} bash -c "\
112133
/test/bin/verify-languages.sh; \
113134
/test/bin/verify-packages.sh; \
114135
"

0 commit comments

Comments
 (0)