Skip to content

Commit aa74ac9

Browse files
fix(docker): simplify artifact extraction
1 parent 7087c6b commit aa74ac9

1 file changed

Lines changed: 13 additions & 34 deletions

File tree

.github/workflows/__call-docker.yml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
# Comma separated list of platforms to run for PR events, i.e. `# platforms_pr: linux/amd64`. This will take
1212
# precedence over the `# platforms: ` directive.
1313
# `# artifacts: `
14-
# `true` to build in two steps, stopping at `artifacts` build stage and extracting the image from there to the
15-
# GitHub runner.
14+
# `true` to extract artifacts from the `/artifacts` directory to the GitHub runner.
1615

1716
name: Docker (called)
1817
permissions:
@@ -259,29 +258,6 @@ jobs:
259258
username: ${{ secrets.GH_BOT_NAME }}
260259
password: ${{ secrets.GH_BOT_TOKEN }}
261260

262-
- name: Build artifacts
263-
if: steps.prepare.outputs.artifacts == 'true'
264-
id: build_artifacts
265-
uses: docker/build-push-action@v6
266-
with:
267-
context: ./
268-
file: ${{ matrix.dockerfile }}
269-
target: artifacts
270-
outputs: type=local,dest=artifacts
271-
push: false
272-
platforms: ${{ steps.prepare.outputs.platforms }}
273-
build-args: |
274-
BRANCH=${{ steps.prepare.outputs.branch }}
275-
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
276-
BUILD_VERSION=${{ inputs.release_tag }}
277-
COMMIT=${{ inputs.release_commit }}
278-
CLONE_URL=${{ steps.prepare.outputs.clone_url }}
279-
RELEASE=${{ inputs.publish_release }}
280-
tags: ${{ steps.prepare.outputs.tags }}
281-
cache-from: type=local,src=/tmp/.buildx-cache
282-
cache-to: type=local,dest=/tmp/.buildx-cache
283-
no-cache-filters: ${{ steps.prepare.outputs.no_cache_filters }}
284-
285261
- name: Build and push
286262
id: build
287263
uses: docker/build-push-action@v6
@@ -301,34 +277,37 @@ jobs:
301277
cache-from: type=local,src=/tmp/.buildx-cache
302278
cache-to: type=local,dest=/tmp/.buildx-cache
303279
no-cache-filters: ${{ steps.prepare.outputs.no_cache_filters }}
280+
outputs: ${{ steps.prepare.outputs.artifacts == 'true' && 'type=local,dest=image' || '' }}
304281

305282
- name: Arrange Artifacts
306283
if: steps.prepare.outputs.artifacts == 'true'
307-
working-directory: artifacts
284+
working-directory: image
308285
run: |
309-
# debug directory
310-
echo "Current directory: $(pwd)"
311-
echo "Directory contents: $(ls -Ra)"
286+
# create artifacts directory
287+
mkdir -p ../artifacts
312288
313289
# artifacts will be in sub directories named after the docker target platform, e.g. `linux_amd64`
314290
# so move files to the artifacts directory
315291
# https://unix.stackexchange.com/a/52816
292+
echo "::group::Moving artifacts"
316293
find \
317294
./ \
318295
-maxdepth 2 \
319296
-mindepth 2 \
297+
-path "*/artifacts/*" \
320298
-type f \
321-
-not -name 'provenance.json' \
322-
-exec mv -t ./ -n '{}' +
299+
-exec mv -t ../artifacts/ -n '{}' +
300+
echo "::endgroup::"
323301
324-
# remove provenance file
325-
rm -f ./provenance.json
302+
echo "::group::Artifacts"
303+
ls -la ../artifacts/
304+
echo "::endgroup::"
326305
327306
- name: Upload Artifacts
328307
if: steps.prepare.outputs.artifacts == 'true'
329308
uses: actions/upload-artifact@v4
330309
with:
331-
name: Docker${{ matrix.tag }}
310+
name: build-Docker${{ matrix.tag }}
332311
path: artifacts/
333312
if-no-files-found: error
334313

0 commit comments

Comments
 (0)