From 2f21ddae5ac0b4521453359567d6c4d9056fae48 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 17 Oct 2024 20:20:20 -0700 Subject: [PATCH] Refine reclaim space script See gh-42776 --- .github/scripts/reclaim-docker-diskspace.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/scripts/reclaim-docker-diskspace.sh b/.github/scripts/reclaim-docker-diskspace.sh index 8c404f87fa..cbf9cfd050 100755 --- a/.github/scripts/reclaim-docker-diskspace.sh +++ b/.github/scripts/reclaim-docker-diskspace.sh @@ -6,11 +6,15 @@ docker image ls --format "{{.Size}} {{.ID}} {{.Repository}} {{.Tag}}" | LANG=en_ image=$( echo "$line" | cut -d' ' -f2 ) repository=$( echo "$line" | cut -d' ' -f3 ) tag=$( echo "$line" | cut -d' ' -f4 ) - if [ "$tag" != "" ]; then - if [ "$size" -gt 200000000 ]; then - echo "Cleaning $image $repository:$size" - docker image rm $image - fi + if [[ "$tag" =~ ^[a-f0-9]{32}$ ]]; then + echo "Ignoring GitHub action image $image $repository:$tag" + elif [[ "$tag" == "" ]]; then + echo "Ignoring untagged image $image $repository:$tag" + elif [[ "$size" -lt 200000000 ]]; then + echo "Ignoring small image $image $repository:$tag" + else + echo "Cleaning $image $repository:$tag" + docker image rm $image fi done