Skip to content

Commit 747d383

Browse files
committed
ci: clean-up PR caches
1 parent 02f17e8 commit 747d383

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/CacheClean.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Cleanup Branch Cache
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Cleanup
13+
run: |
14+
gh extension install actions/gh-actions-cache
15+
16+
echo "Fetching list of cache key"
17+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
18+
19+
## Setting this to not fail the workflow while deleting cache keys.
20+
set +e
21+
echo "Deleting caches..."
22+
for cacheKey in $cacheKeysForPR
23+
do
24+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
25+
done
26+
echo "Done"
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
REPO: ${{ github.repository }}
30+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

0 commit comments

Comments
 (0)