File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 workflow_dispatch :
44
55jobs :
6+ clear_cache :
7+ runs-on : ubuntu-latest
8+ permissions :
9+ actions : write
10+ steps :
11+ - name : Delete old caches (except TestData)
12+ env :
13+ GH_TOKEN : ${{ github.token }}
14+ run : |
15+ cutoff=$(date -d '14 days ago' +%s)
16+
17+ gh api \
18+ -H "Accept : application/vnd.github+json" \
19+ " /repos/${{ github.repository }}/actions/caches?per_page=100" \
20+ --paginate \
21+ --jq '.actions_caches[]' | \
22+ jq -r --arg cutoff "$cutoff" '
23+ select(.key | startswith("TestData-") | not) |
24+ select((.last_accessed_at | sub("\\..*Z$"; "Z") | fromdateiso8601) < ($cutoff | tonumber)) |
25+ " \( .id) \( .key)"
26+ ' | while read cache_id cache_key; do
27+ if [ -n "$cache_id" ]; then
28+ echo "Deleting cache $cache_id ($cache_key)"
29+ gh api --method DELETE \
30+ -H "Accept: application/vnd.github+json" \
31+ "/repos/${{ github.repository }}/actions/caches/$cache_id" || true
32+ fi
33+ done
34+
635 cache:
736 runs-on: ubuntu-latest
837 outputs:
You can’t perform that action at this time.
0 commit comments