Skip to content

Leave only the latest cache of the corresponding key in GitHub Actions

License

Notifications You must be signed in to change notification settings

lapla-cogito/only-latest-cache

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

only-latest-cache

Clear the cache with the prefix key specified in GitHub Actions except the most recent one

Usage

example:

- name: Use Node.js
  uses: actions/setup-node@v4
  with:
    node-version: ${{ matrix.node-version }}
    cache: 'pnpm'
- name: Leave only latest cache
  uses: lapla-cogito/only-latest-cache@v1
  with:
    key_prefix: 'node-cache-Linux-pnpm'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

In this example, this action will delete the cache of Node.js except the last accessed one, which is the cache of the branch ref on which the workflow runs. Make sure that the token passed to GITHUB_TOKEN has write permission to Actions.

About

Leave only the latest cache of the corresponding key in GitHub Actions

Topics

Resources

License

Stars

Watchers

Forks