forked from R3BRootGroup/R3BRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
33 lines (27 loc) · 989 Bytes
/
cleanup_cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 "actions@github.com" && 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 }}