Skip to content

Commit

Permalink
cache cleanuper
Browse files Browse the repository at this point in the history
  • Loading branch information
reymondzzzz committed Mar 7, 2024
1 parent 90591af commit bd50573
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
pull_request:
workflow_dispatch:
repository_dispatch:
workflow_run:
workflows: ["Cache cleanup"]
types:
- completed


env:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/cache_cleanuper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Cache cleanup

on:
schedule:
- cron: '0 0 * * 6'
workflow_dispatch:
repository_dispatch:

jobs:
cache-cleanup:
runs-on: ubuntu-latest
steps:
- name: Clear cache
uses: actions/github-script@v6
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")

0 comments on commit bd50573

Please sign in to comment.