ci: fix jq broken pipe in cache-prune (#38734)

Fix minor issue: `cache-prune` logs `jq: error: writing output failed:
Broken pipe` when it has nothing to delete, because the loop stops
reading as soon as it is under the limit while `jq` still has output
pending. Reading from a here-string removes the pipe.

---------

Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
silverwind
2026-08-02 14:57:37 +02:00
committed by GitHub
parent d390d77879
commit b87fdd5da4
+5 -6
View File
@@ -30,9 +30,8 @@ jobs:
caches=$(gh cache list --limit 1000 --sort last_accessed_at --order asc --json id,key,sizeInBytes)
size=$(jq '[.[].sizeInBytes] | add // 0' <<< "$caches")
echo "cache usage: $((size / 1000000)) MB"
jq -r '.[] | "\(.id) \(.sizeInBytes) \(.key)"' <<< "$caches" |
while [ "$size" -gt 6500000000 ] && read -r id bytes key; do
echo "deleting $key"
gh cache delete "$id"
size=$((size - bytes))
done
while [ "$size" -gt 6500000000 ] && read -r id bytes key; do
echo "deleting $key"
gh cache delete "$id"
size=$((size - bytes))
done <<< "$(jq -r '.[] | "\(.id) \(.sizeInBytes) \(.key)"' <<< "$caches")"