A GitHub Action that deletes GitHub Actions caches by key prefix using the GitHub REST API. Useful for cleaning up stale or unwanted caches, for example after a pull request is merged or closed.
- Delete caches matching a key prefix
- Optionally scope deletion to a specific git ref
- Reports the number of successfully deleted caches
- Detailed logging with cache sizes and freed space
- Graceful handling of partial failures
- uses: kula-app/clean-cache-action@v1
with:
key: some-cache-key-prefix| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key |
string | Yes | Cache key prefix to match for deletion | |
ref |
string | No | Git ref to scope cache deletion (e.g. refs/heads/main) | |
token |
string | No | ${{ github.token }} |
GitHub token with actions:write permission |
| Name | Description |
|---|---|
deleted-count |
Number of caches successfully deleted |
This action requires the actions: write permission to delete caches:
permissions:
actions: writename: Clean PR Caches
on:
pull_request:
types: [closed]
permissions:
actions: write
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: kula-app/clean-cache-action@v1
with:
key: pr-${{ github.event.pull_request.number }}
ref: refs/pull/${{ github.event.pull_request.number }}/merge# Install dependencies
pnpm install
# Run tests
pnpm test
# Lint
pnpm lint
# Format
pnpm format
# Build dist
pnpm build
# Run all checks
pnpm all