cache icon indicating copy to clipboard operation
cache copied to clipboard

Feat: Control whether caches are written

Open helly25 opened this issue 9 months ago • 3 comments

In some cases you want to read but not save a new cache. For instance when you run workflows on a tag action, then you probably want to read caches from the main/default branch, but you most likely do not want to create new caches. The current solution is to separate restore and save actions which is cumbersome.

In https://github.com/actions/cache/pull/1452 the always_save feature was removed.

I propose to add a new config save-on-success that defaults to true and can be set false to prevent cache writing. Now this new value can be set from available context - just like you could when separating the steps - granted the decision must be available upfront. That above described decision is in fact available immediately on job creation. So we can use the new setting to simplify the setup.

helly25 avatar Mar 11 '25 20:03 helly25

A proposal to implement this is in https://github.com/actions/cache/pull/1571

helly25 avatar Mar 11 '25 20:03 helly25

See also https://github.com/actions/cache/discussions/1598

helly25 avatar Apr 25 '25 13:04 helly25

This would be very helpful to have.

iwahbe avatar Jul 16 '25 18:07 iwahbe