Skip to content

Commit 9661f94

Browse files

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: cleanup branch caches
3+
4+
on:
5+
pull_request:
6+
types:
7+
- closed
8+
9+
jobs:
10+
cleanup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- run: gh extension install actions/gh-actions-cache
14+
15+
- name: Cleanup
16+
run: |
17+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1)
18+
19+
# Turn off errexit 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+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
29+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

0 commit comments

Comments
 (0)