Skip to content

Commit a1ae023

Browse files
committed
CI: clear nightly Rust caches
1 parent 2fb8033 commit a1ae023

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Evict stale nightly Rust caches
2+
on:
3+
schedule:
4+
# every 12 hours
5+
- cron: "0 */12 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup:
10+
permissions:
11+
actions: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Delete nightly Rust caches older than 48h
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
REPO: ${{ github.repository }}
18+
run: |
19+
CUTOFF=$(date -u -d '48 hours ago' +%s)
20+
21+
CACHE_IDS=$(gh cache list --repo "$REPO" --limit 500 \
22+
--json id,key,createdAt \
23+
--jq --argjson cutoff "$CUTOFF" \
24+
'.[] | select(.key | startswith("v0-rust-nightly"))
25+
| select((.createdAt | sub("\\.[0-9]+"; "") | fromdateiso8601) < $cutoff)
26+
| .id')
27+
28+
for CACHE_ID in $CACHE_IDS; do
29+
echo "Deleting cache $CACHE_ID"
30+
gh cache delete "$CACHE_ID" --repo "$REPO"
31+
done

0 commit comments

Comments
 (0)