Skip to content

Commit e0c23cd

Browse files
mroeschkeim-vinicius
authored and
im-vinicius
committed
CI: Clean caches of closed PRs (pandas-dev#53184)
1 parent 2a827ab commit e0c23cd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/cache-cleanup.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Clean closed branch caches
2+
on:
3+
pull_request:
4+
types:
5+
- closed
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+
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
17+
18+
echo "Fetching list of cache key"
19+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
20+
21+
## Setting this to not fail the workflow while deleting cache keys.
22+
set +e
23+
echo "Deleting caches..."
24+
for cacheKey in $cacheKeysForPR
25+
do
26+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
27+
done
28+
echo "Done"
29+
env:
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)