Skip to content

Cleanup old caches

Cleanup old caches #9

Workflow file for this run

name: Cleanup Old Caches
on:
schedule:
- cron: '0 0 * * 0'
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Git
run: git config --global user.email "actions@github.com" && git config --global user.name "GitHub Actions"
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache keys"
cacheKeys=$(gh actions-cache list -R R3BRootGroup/R3BRoot -L 100 | cut -f 1 | grep -v 'build-deps')
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting old caches..."
for cacheKey in $cacheKeys
do
gh actions-cache delete $cacheKey -R R3BRootGroup/R3BRoot --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}