Skip to content

Commit dad7e3d

Browse files
committedOct 29, 2024
ci: Add workflow to manually cleanup largest 100 caches
1 parent b0b694f commit dad7e3d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Cleanup lages 100 caches
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
packages: read
9+
actions: write
10+
11+
jobs:
12+
cleanup:
13+
name: Delete caches when PR is closed
14+
runs-on: ubuntu-24.04
15+
16+
steps:
17+
- name: Cleanup largest 100 caches
18+
run: |
19+
echo "Fetching list of cache key"
20+
cacheKeysLargest=$(gh cache list -R $REPO --limit 100 --sort size_in_bytes --order desc| cut -f 1 )
21+
22+
## Setting this to not fail the workflow while deleting cache keys.
23+
set +e
24+
echo "Deleting caches..."
25+
for cacheKey in $cacheKeysLargest
26+
do
27+
gh cache delete $cacheKey -R $REPO -B $BRANCH --confirm
28+
done
29+
echo "Done"
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
REPO: ${{ github.repository }}

0 commit comments

Comments
 (0)
Please sign in to comment.