Skip to content

Commit e1b196f

Browse files
committed
ops: fix sccache ci; add cleanup action
1 parent 1a112c0 commit e1b196f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77
CARGO_TERM_COLOR: always
88
RUST_BACKTRACE: 1
99
MISE_ENV: ci
10+
SCCACHE_GHA_ENABLED: true
1011

1112
jobs:
1213
build_and_test:

.github/workflows/cleanup.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches
2+
3+
name: Cleanup github runner caches on closed pull requests
4+
on:
5+
pull_request:
6+
types:
7+
- closed
8+
9+
jobs:
10+
cleanup:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
actions: write
14+
steps:
15+
- name: Cleanup
16+
run: |
17+
echo "Fetching list of cache keys"
18+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
19+
20+
## Setting this to not fail the workflow while deleting cache keys.
21+
set +e
22+
echo "Deleting caches..."
23+
for cacheKey in $cacheKeysForPR
24+
do
25+
gh cache delete $cacheKey
26+
done
27+
echo "Done"
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
GH_REPO: ${{ github.repository }}
31+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

0 commit comments

Comments
 (0)