File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Cleanup Actions Storage
2+
3+ on :
4+ schedule :
5+ - cron : " 17 3 * * *"
6+ workflow_dispatch :
7+
8+ permissions :
9+ actions : write
10+ contents : read
11+
12+ jobs :
13+ cleanup :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Delete artifacts and caches older than 7 days
17+ env :
18+ GH_TOKEN : ${{ github.token }}
19+ REPO : ${{ github.repository }}
20+ run : |
21+ cutoff=$(date -u -d "7 days ago" +%Y-%m-%dT%H:%M:%SZ)
22+
23+ gh api "repos/$REPO/actions/artifacts" --paginate \
24+ --jq ".artifacts[] | select(.created_at < \"$cutoff\") | .id" |
25+ while read -r id; do
26+ [ -n "$id" ] && gh api -X DELETE "repos/$REPO/actions/artifacts/$id"
27+ done
28+
29+ gh api "repos/$REPO/actions/caches" --paginate \
30+ --jq ".actions_caches[] | select(.last_accessed_at < \"$cutoff\") | .id" |
31+ while read -r id; do
32+ [ -n "$id" ] && gh api -X DELETE "repos/$REPO/actions/caches/$id"
33+ done
You can’t perform that action at this time.
0 commit comments