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
Context
Currently,
cache: trueenables 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
mainordevelop.Right now, to achieve this, you either have to disable caching on PRs altogether (losing restoration entirely) or manually wire up
actions/cache/restoreandactions/cache/saveto 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-saveinput (defaulting totrueto avoid breaking changes).The matrix would look like this:
cachecache-savefalsetruetruetruefalseEssentially, the post action would only save the cache when both
cacheandcache-saveare enabled.For reference,
mise-actionimplements a similar option:https://github.com/jdx/mise-action/blob/0c6ea298a49e2fc9b6b8ec854c2e6c292490f032/action.yml#L55-L58