File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ jobs:
246246 cache-to : |
247247 ${{ steps.metadata.outputs.cache_to }}
248248
249- # Pack the Docker images into manifest lists .
249+ # Merge all architecture images into manifest list .
250250 manifest :
251251 if : ${{ github.event.inputs.dry_run == 'false' }}
252252 needs :
Original file line number Diff line number Diff line change 1+ # This workflow squashes Docker images' layers to reduce the image size.
2+ # It supports squashing images for multiple OS/ARCH and creating manifest list.
3+ # The workflow is triggered manually via GitHub Actions UI.
4+
15name : squash
26
37permissions :
@@ -98,3 +102,35 @@ jobs:
98102 INPUT_DST_IMAGE : ${{ matrix.dst_image }}
99103 INPUT_PLATFORM : ${{ matrix.platform }}
100104 run : ${{ github.workspace }}/pack/squash_image.sh
105+
106+ # Merge all architecture images into manifest list.
107+ manifest :
108+ needs :
109+ - expand-matrix
110+ - squash
111+ runs-on : ubuntu-22.04
112+ steps :
113+ - name : Login DockerHub
114+ uses : docker/login-action@v3
115+ with :
116+ username : ${{ env.INPUT_USERNAME }}
117+ password : ${{ env.INPUT_PASSWORD }}
118+ - name : Manifest
119+ env :
120+ INPUT_MANIFEST_JOBS : ${{ needs.expand-matrix.outputs.manifest_jobs }}
121+ run : |
122+ #!/usr/bin/env bash
123+
124+ set -eo pipefail
125+
126+ # Iterate all items of manifest jobs.
127+ for IMAGE in $(echo "${INPUT_MANIFEST_JOBS}" | jq -r 'keys[]'); do
128+ PLATFORM_IMAGES="$(echo "${INPUT_MANIFEST_JOBS}" | jq -r \
129+ --arg image "${IMAGE}" \
130+ '.[$image] | join(" ")')"
131+ echo "[INFO]: Creating manifest '${IMAGE}' with '${PLATFORM_IMAGES}'"
132+ docker manifest create --amend "${IMAGE}" ${PLATFORM_IMAGES}
133+ docker manifest inspect "${IMAGE}"
134+ echo "[INFO]: Pushing manifest '${IMAGE}'"
135+ docker manifest push --purge "${IMAGE}"
136+ done
You can’t perform that action at this time.
0 commit comments