Skip to content

Cleanup old caches

Cleanup old caches #18

Workflow file for this run

name: Cleanup old caches
on:
schedule:
- cron: '0 0 1 */2 *'
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Git
run: git config --global user.email "[email protected]" && git config --global user.name "GitHub Actions"
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache || exit 1
echo "Fetching list of cache keys"
cacheKeys=$(gh actions-cache list -R R3BRootGroup/R3BRoot -L 100 | cut -f 1 | grep -v 'build-deps') || exit 1
## 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 || exit 1
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}