Skip to content

Commit 12cfc16

Browse files
authored
CI: Clean GH Action caches weekly (#53753)
* CI: Clean GH Action caches older than 1 week * purge weekly instead * ensure we list a lot of caches
1 parent d32d025 commit 12cfc16

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Purge caches once a week
2+
on:
3+
schedule:
4+
# 4:10 UTC on Sunday
5+
- cron: "10 4 * * 0"
6+
7+
jobs:
8+
cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Clean Cache
12+
run: |
13+
gh extension install actions/gh-actions-cache
14+
15+
REPO=${{ github.repository }}
16+
17+
echo "Fetching list of cache key"
18+
allCaches=$(gh actions-cache list -L 100 -R $REPO | cut -f 1 )
19+
20+
## Setting this to not fail the workflow while deleting cache keys.
21+
set +e
22+
echo "Deleting caches..."
23+
for cacheKey in $allCaches
24+
do
25+
gh actions-cache delete $cacheKey -R $REPO --confirm
26+
done
27+
echo "Done"
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)