Skip to content

Commit 7771a5c

Browse files
committed
refactor: update action
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 5f43ed9 commit 7771a5c

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

.github/workflows/pack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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:

.github/workflows/squash.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
name: squash
26

37
permissions:
@@ -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

0 commit comments

Comments
 (0)