clear-cache.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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@v7
  12. with:
  13. script: |
  14. console.log("About to clear")
  15. const caches = await github.rest.actions.getActionsCacheList({
  16. owner: context.repo.owner,
  17. repo: context.repo.repo,
  18. })
  19. for (const cache of caches.data.actions_caches) {
  20. console.log(cache)
  21. github.rest.actions.deleteActionsCacheById({
  22. owner: context.repo.owner,
  23. repo: context.repo.repo,
  24. cache_id: cache.id,
  25. })
  26. }
  27. console.log("Clear completed")
  28. - name: Purge cache # Above seems not clear thouroughly, so add this to double clear
  29. uses: MyAlbum/purge-cache@v2
  30. with:
  31. accessed: true # Purge caches by their last accessed time (default)
  32. created: false # Purge caches by their created time (default)
  33. max-age: 1 # in seconds