-
-
Notifications
You must be signed in to change notification settings - Fork 64
53 lines (47 loc) · 1.59 KB
/
Copy pathcache.yml
File metadata and controls
53 lines (47 loc) · 1.59 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Refresh cache
on:
schedule:
- cron: '0 2 * * 1' # Mondays at 2 AM UTC
workflow_dispatch:
permissions: {}
jobs:
clear_cache:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete old caches (except TestData)
env:
GH_TOKEN: ${{ github.token }}
run: |
cutoff=$(date -d '5 days ago' +%s)
gh api \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches?per_page=100" \
--paginate \
--jq '.actions_caches[]' | \
jq -r --arg cutoff "$cutoff" '
select(.key | startswith("TestData-") | not) |
select((.last_accessed_at | sub("\\..*Z$"; "Z") | fromdateiso8601) < ($cutoff | tonumber)) |
"\(.id) \(.key)"
' | while read cache_id cache_key; do
if [ -n "$cache_id" ]; then
echo "Deleting cache $cache_id ($cache_key)"
gh api --method DELETE \
-H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/actions/caches/$cache_id" || true
fi
done
cache:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.data_cache.outputs.cache_key }}
permissions:
actions: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- id: data_cache
uses: ./.github/actions/data-cache
- uses: ./.github/actions/native-data-cache
with:
cache_key: ${{ steps.data_cache.outputs.cache_key }}