Skip to content

Commit 35679e2

Browse files
committed
automatic clean of cache every month.
1 parent d466c26 commit 35679e2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/clean_cache.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Clear cache
2+
3+
on:
4+
schedule:
5+
# Monthly day 1 at 0:35 UTC.
6+
- cron: '35 0 1 1-12 *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
actions: write
11+
12+
jobs:
13+
clear-cache:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Clear cache
17+
uses: actions/github-script@v6
18+
with:
19+
script: |
20+
console.log("About to clear")
21+
const caches = await github.rest.actions.getActionsCacheList({
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
})
25+
for (const cache of caches.data.actions_caches) {
26+
console.log(cache)
27+
github.rest.actions.deleteActionsCacheById({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
cache_id: cache.id,
31+
})
32+
}
33+
console.log("Clear completed")

0 commit comments

Comments
 (0)