Skip to content

Clear cache

Clear cache #19

Workflow file for this run

---
name: Clear cache
on:
workflow_dispatch:
permissions:
contents: read
jobs:
clear-cache:
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- name: Clear cache
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
## The maximum GH fetch limit is 100
cacheKeysForPR=$(gh actions-cache list -R $REPO -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}