Skip to content

Cache Cleanup

Cache Cleanup #8

Workflow file for this run

name: Cache Cleanup
permissions:
actions: write
on:
schedule:
- cron: 0 0 1 * * # Monthly cleanup
workflow_dispatch: # Manual trigger
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: main
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeys=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeys
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done