Replies: 1 comment 1 reply
|
At the moment this is not a built-in For a pushed image, you can append the compressed registry size yourself. One important detail: for a multi-platform image there is no single runtime image size, so report each platform. Also, do not sum the - name: Build and push
id: build
uses: docker/build-push-action@v7
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ env.IMAGE }}:${{ github.sha }}
- name: Add published image size to summary
shell: bash
env:
IMAGE: ${{ env.IMAGE }}:${{ github.sha }}
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
ref="${IMAGE}@${DIGEST}"
root_manifest="$(docker buildx imagetools inspect "$ref" --raw)"
manifest_bytes() {
docker buildx imagetools inspect "$1" --raw \
| jq '[(.config.size // 0), (.layers[]?.size // 0)] | add'
}
format_mib() {
awk -v bytes="$1" 'BEGIN { printf "%.2f MiB", bytes / 1048576 }'
}
{
echo '### Published image size'
echo
if jq -e '.manifests? | type == "array"' >/dev/null <<<"$root_manifest"; then
echo '| Platform | Compressed size |'
echo '|---|---:|'
while IFS=$'\t' read -r platform digest; do
bytes="$(manifest_bytes "${IMAGE}@${digest}")"
echo "| \`${platform}\` | $(format_mib "$bytes") |"
done < <(
jq -r '
.manifests[]
| select(.platform.os? != null and .platform.os != "unknown")
| [
([.platform.os, .platform.architecture, .platform.variant]
| map(select(. != null and . != "")) | join("/")),
.digest
]
| @tsv
' <<<"$root_manifest"
)
else
bytes="$(jq '[(.config.size // 0), (.layers[]?.size // 0)] | add' <<<"$root_manifest")"
echo "- \`${ref}\`: **$(format_mib "$bytes")**"
fi
echo
echo '_Compressed registry bytes (config + layers), not uncompressed local disk usage._'
} >> "$GITHUB_STEP_SUMMARY"This measures the immutable digest and handles both a single-platform manifest and a multi-platform index. The If you use Sources: |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to know if it was possible to consider adding the size (in Mb/Gb) of the image(s) built in the github action summary?
All reactions