wipe_cache.yml 1014 B

12345678910111213141516171819202122232425262728293031323334353637
  1. name: Clear cache
  2. on:
  3. workflow_dispatch:
  4. permissions:
  5. actions: write
  6. jobs:
  7. clear-cache:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Clear cache
  11. uses: actions/github-script@v6
  12. with:
  13. github-token: ${{ secrets.cache_controller }}
  14. script: |
  15. console.log("About to clear")
  16. while (true) {
  17. const caches = await github.rest.actions.getActionsCacheList({
  18. owner: context.repo.owner,
  19. repo: context.repo.repo
  20. })
  21. if (caches.data.actions_caches.length === 0) {
  22. break
  23. }
  24. for (const cache of caches.data.actions_caches) {
  25. console.log(cache)
  26. github.rest.actions.deleteActionsCacheById({
  27. owner: context.repo.owner,
  28. repo: context.repo.repo,
  29. cache_id: cache.id,
  30. })
  31. }
  32. }
  33. console.log("Clear completed")