Skip to content

Add a cache-save input to support restore-only dependency caching #139

Description

@naokihaba

Context

Currently, cache: true enables both cache restoration in the main action and cache saving in the post action.

In many setups, it is desirable to restore caches on every branch and PR, but only write new caches from a default or trusted branch like main or develop.

Right now, to achieve this, you either have to disable caching on PRs altogether (losing restoration entirely) or manually wire up actions/cache/restore and actions/cache/save to mimic setup-vp's internal cache paths and key generation. The latter is brittle because it duplicates internal logic and easily drifts over time.

Proposal

It would be great to add an optional cache-save input (defaulting to true to avoid breaking changes).

- uses: voidzero-dev/setup-vp@v1.18.0
  with:
    cache: true
    cache-save: ${{ github.ref == 'refs/heads/develop' }}

The matrix would look like this:

cache cache-save Restore Save
false Any value No No
true Omitted or true Yes Yes
true false Yes No

Essentially, the post action would only save the cache when both cache and cache-save are enabled.

For reference, mise-action implements a similar option:
https://github.com/jdx/mise-action/blob/0c6ea298a49e2fc9b6b8ec854c2e6c292490f032/action.yml#L55-L58

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions