Cockatrice/.github/workflows/delete-merged-caches.yml
Bruno Alexandre Rosa 33e5cd0fa9
Update .github/workflows/delete-merged-caches.yml
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2025-12-31 12:17:04 +01:00

28 lines
806 B
YAML

# from https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches
name: Cleanup github runner caches on closed pull requests
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup
run: |
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey || true
done
echo "Done"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge