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: