Skip to content

Add workflow to delete caches on closed PRs #2

Add workflow to delete caches on closed PRs

Add workflow to delete caches on closed PRs #2

Workflow file for this run

name: Cleanup caches on closed pull requests

Check failure on line 1 in .github/workflows/clean_caches.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/clean_caches.yml

Invalid workflow file

(Line: 12, Col: 16): Unexpected value 'write-all'
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
# needs to be refined
actions: write-all
steps:
- name: Cleanup caches
run: |
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey
done
echo "Done"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge