workflows/cleanup_caches: minor cosmetic changes

This commit is contained in:
Kacper Michajłow 2024-05-20 16:58:37 +02:00
parent 2697a8c362
commit 7924afcba0
1 changed files with 4 additions and 4 deletions

View File

@ -10,8 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- run: | - run: |
caches=$(gh cache list -R ${{ github.repository }} -L 100 --json id,key,ref -S last_accessed_at -O desc) gh cache list -L 100 --json id,key,ref -S last_accessed_at -O desc --jq '
echo "$caches" | jq -c '
map(select(.key | startswith("x86_64-w64-mingw32-") or map(select(.key | startswith("x86_64-w64-mingw32-") or
startswith("i686-w64-mingw32-") or startswith("i686-w64-mingw32-") or
startswith("x86_64-windows-msvc-"))) | startswith("x86_64-windows-msvc-"))) |
@ -27,14 +26,15 @@ jobs:
' | ' |
while read -r group; do while read -r group; do
pr=$(echo "$group" | jq -r '.ref | capture("refs/pull/(?<num>[0-9]+)/merge").num') 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 if [[ -n "$pr" ]] && [ "$(gh pr view $pr --json state --jq '.state')" != "OPEN" ]; then
keys=$(echo "$group" | jq -c '.caches | map(.keys) | .[]') keys=$(echo "$group" | jq -c '.caches | map(.keys) | .[]')
else else
keys=$(echo "$group" | jq -c '.caches | map(.keys[1:]) | .[]') keys=$(echo "$group" | jq -c '.caches | map(.keys[1:]) | .[]')
fi fi
for key in $(echo "$keys" | jq -r '.[]'); do for key in $(echo "$keys" | jq -r '.[]'); do
gh cache delete "$key" -R ${{ github.repository }} gh cache delete "$key"
done done
done done
env: env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}