diff --git a/.github/workflows/docker-build-cloud.yml b/.github/workflows/docker-build-cloud.yml index 0858331..2d5165e 100644 --- a/.github/workflows/docker-build-cloud.yml +++ b/.github/workflows/docker-build-cloud.yml @@ -38,10 +38,16 @@ on: dockerhub-password: description: "DockerHub PAT with Build scope (required to authenticate to Docker Build Cloud endpoint)" required: true + outputs: + checksum: + description: "Checksum (0x) of the pushed multi-arch image index" + value: ${{ jobs.build.outputs.checksum }} jobs: build: runs-on: ubuntu-latest + outputs: + checksum: ${{ steps.checksum.outputs.checksum }} steps: - name: Checkout Repository @@ -62,6 +68,7 @@ jobs: endpoint: ${{ inputs.cloud-builder-endpoint }} - name: Build and push multi-platform image + id: build uses: docker/build-push-action@v7 with: build-args: ${{ inputs.build-args }} @@ -70,3 +77,13 @@ jobs: platforms: ${{ inputs.platforms }} push: true tags: ${{ inputs.image-name }}:${{ inputs.image-tag }} + + - name: Compute checksum of the Docker image + id: checksum + # avoid shell injection through string interpolation + env: + DIGEST: ${{ steps.build.outputs.digest }} + run: | + # build-push-action returns the pushed multi-arch INDEX digest as "sha256:". + # Expose it as "0x" to match the docker-build.yml output format. + echo "checksum=0x${DIGEST#sha256:}" | tee -a "$GITHUB_OUTPUT" diff --git a/docker-build-cloud/README.md b/docker-build-cloud/README.md index e6371cd..d013feb 100644 --- a/docker-build-cloud/README.md +++ b/docker-build-cloud/README.md @@ -10,6 +10,7 @@ This reusable GitHub Actions workflow builds and pushes a multi-platform Docker - ๐Ÿ” Authenticates to DockerHub for both registry push and DBC endpoint access - ๐Ÿท๏ธ Tags the image with `:` - ๐Ÿš€ No QEMU emulation, no native ARM runners โ€” DBC handles arch-specific builds +- ๐Ÿงพ Exposes the pushed multi-arch image index digest as a `checksum` output > [!IMPORTANT] > Requires a Docker Build Cloud subscription and a builder configured in your DockerHub organization. The DockerHub PAT must have the **Build** scope to authenticate to the cloud endpoint. @@ -33,6 +34,12 @@ This reusable GitHub Actions workflow builds and pushes a multi-platform Docker | `dockerhub-username` | Username for Docker Hub authentication | Yes | | `dockerhub-password` | Personal Access Token for Docker Hub with the **Build** scope (needed for DBC endpoint) | Yes | +## ๐Ÿ“ค Outputs + +| Name | Description | +| ---------- | ----------------------------------------------------------------- | +| `checksum` | Checksum (`0x`) of the pushed multi-arch image index | + ## ๐Ÿ’ป Example Usage ```yaml