-
Notifications
You must be signed in to change notification settings - Fork 28
39 lines (34 loc) · 1.03 KB
/
post-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: PostPR
on:
pull_request:
types:
- closed
jobs:
cleanup_cache:
name: Clean Up Ccache Cache Post PR
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccache
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
pr_number=${{ github.event.number }}
echo "Clean up cache for PR ${pr_number}."
BRANCH=refs/pull/${pr_number}/merge
# Setting this to not fail the workflow while deleting cache keys.
set +e
# Delete all entries associated with this PR.
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
# $keys might contain spaces. Thus we set IFS to \n.
IFS=$'\n'
for k in $keys
do
gh actions-cache delete "$k" -R $REPO -B $BRANCH --confirm
done
unset IFS