mirror of https://github.com/mpv-player/mpv
ci/cleanup_caches: group by cache prefixes too
I've simplified this too much during refactoring, forgot about this. We
need to preserve the latest cache with each prefix.
Fixes: c6b950ae1e
This commit is contained in:
parent
c6b950ae1e
commit
0c85b9915f
|
@ -18,16 +18,19 @@ jobs:
|
|||
group_by(.ref) |
|
||||
map({
|
||||
ref: .[0].ref,
|
||||
caches: map(.key)
|
||||
caches: map({
|
||||
key: .key,
|
||||
prefix: (.key | capture("^(?<prefix>[\\w_-]+-)\\d+$").prefix)
|
||||
}) | group_by(.prefix) | map({keys: map(.key)})
|
||||
}) |
|
||||
.[]
|
||||
' |
|
||||
while read -r group; do
|
||||
pr=$(echo "$group" | jq -r '.ref | capture("refs/pull/(?<num>[0-9]+)/merge").num')
|
||||
if [[ -n "$pr" ]] && [ "$(gh pr view -R ${{ github.repository }} $pr --json state --jq '.state')" != "OPEN" ]; then
|
||||
keys=$(echo "$group" | jq -c '.caches')
|
||||
keys=$(echo "$group" | jq -c '.caches | map(.keys) | .[]')
|
||||
else
|
||||
keys=$(echo "$group" | jq -c '.caches[1:]')
|
||||
keys=$(echo "$group" | jq -c '.caches | map(.keys[1:]) | .[]')
|
||||
fi
|
||||
for key in $(echo "$keys" | jq -r '.[]'); do
|
||||
gh cache delete "$key" -R ${{ github.repository }}
|
||||
|
|
Loading…
Reference in New Issue