From 7755f58a47011cd8db7a16e2b681fd2b6809e57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Tue, 29 Sep 2026 20:21:44 +0000 Subject: [PATCH] Docker: add optional test input The new "test" input is a shell command that tests the image before the push. When it is set, the workflow builds the image for linux/amd64, loads it into Docker and runs the command with IMAGE=image:tag. The multi-arch build that follows uses the same builder cache. Callers without "test" are not changed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VSKw7jY45nUJWQxWpvjm82 --- .github/workflows/docker.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3f5b0d1..9e42437 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,6 +30,13 @@ on: required: false type: string + # Shell command to test the image before the push. The workflow first + # builds the image for linux/amd64 and loads it into Docker as + # IMAGE (image:tag). The command runs from the repository root. + test: + required: false + type: string + jobs: docker-workflow: name: "${{ inputs.image }}:${{ inputs.tag }}" @@ -54,6 +61,23 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 + - name: Build test image + if: inputs.test + uses: docker/build-push-action@v7 + with: + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile || format('{0}/Dockerfile', inputs.context) }} + tags: ${{ inputs.image }}:${{ inputs.tag }} + platforms: linux/amd64 + load: true + cache-from: type=gha + + - name: Test + if: inputs.test + env: + IMAGE: ${{ inputs.image }}:${{ inputs.tag }} + run: ${{ inputs.test }} + - name: Build and push uses: docker/build-push-action@v7 with: