Cleans up caches for GitHub Actions by their keys or branches.
The action is designed to be used in two scenarios with minimal setup necessary:
- on push branch event, where it can delete obsolete cache entries
- on PR close event, where it can delete all cache entries belonging to the branch
on:
push:
branches: ['**']
jobs:
clean:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: opengrabeso/[email protected]
with:
post: true
keep: 1
name: PR Cleanup
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
pull-requests: read
steps:
- name: Clean cache for the branch name
uses: opengrabeso/[email protected]