mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-04 16:37:42 +00:00
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:
@@ -30,9 +30,8 @@ jobs:
|
|||||||
caches=$(gh cache list --limit 1000 --sort last_accessed_at --order asc --json id,key,sizeInBytes)
|
caches=$(gh cache list --limit 1000 --sort last_accessed_at --order asc --json id,key,sizeInBytes)
|
||||||
size=$(jq '[.[].sizeInBytes] | add // 0' <<< "$caches")
|
size=$(jq '[.[].sizeInBytes] | add // 0' <<< "$caches")
|
||||||
echo "cache usage: $((size / 1000000)) MB"
|
echo "cache usage: $((size / 1000000)) MB"
|
||||||
jq -r '.[] | "\(.id) \(.sizeInBytes) \(.key)"' <<< "$caches" |
|
while [ "$size" -gt 6500000000 ] && read -r id bytes key; do
|
||||||
while [ "$size" -gt 6500000000 ] && read -r id bytes key; do
|
echo "deleting $key"
|
||||||
echo "deleting $key"
|
gh cache delete "$id"
|
||||||
gh cache delete "$id"
|
size=$((size - bytes))
|
||||||
size=$((size - bytes))
|
done <<< "$(jq -r '.[] | "\(.id) \(.sizeInBytes) \(.key)"' <<< "$caches")"
|
||||||
done
|
|
||||||
|
|||||||
Reference in New Issue
Block a user