Skip to content

kula-app/clean-cache-action

Repository files navigation

Clean Cache Action

CI License: MIT

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.

Features

  • 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

Usage

- uses: kula-app/clean-cache-action@v1
  with:
    key: some-cache-key-prefix

Inputs

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

Outputs

Name Description
deleted-count Number of caches successfully deleted

Permissions

This action requires the actions: write permission to delete caches:

permissions:
  actions: write

Example: Clean Caches on PR Close

name: 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

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Lint
pnpm lint

# Format
pnpm format

# Build dist
pnpm build

# Run all checks
pnpm all

License

MIT

About

GitHub Action that cleans up stale or unwanted GitHub Actions cache

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors