-
-
Notifications
You must be signed in to change notification settings - Fork 64
49 lines (44 loc) · 1.54 KB
/
Copy pathcache.yml
File metadata and controls
49 lines (44 loc) · 1.54 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
name: Refresh cache
on:
schedule:
- cron: '0 2 * * 1' # Mondays at 2 AM UTC
workflow_dispatch:
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 '14 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 }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- id: data_cache
uses: ./.github/actions/data-cache
- uses: ./.github/actions/native-data-cache
with:
cache_key: ${{ steps.data_cache.outputs.cache_key }}