cache icon indicating copy to clipboard operation
cache copied to clipboard

setting to keep cache even if job fails

Open kylrth opened this issue 3 years ago • 2 comments

I use this action for the cache of htmltest, a link checker. Often it'll get through plenty of links before finding a broken one, but because the job fails the cache isn't saved (and so if I re-run the action it has to check all the links again). I'd like for there to be a setting to keep the cache even if the job fails.

kylrth avatar Jul 28 '22 16:07 kylrth

@kylrth cache save happens at the end of workflow run. This happens because the directory/file cached can change till the end of run. Saving cache after every step would create a lot of requests which many users won't want.

Phantsure avatar Aug 10 '22 12:08 Phantsure

That's not what I'm asking for. For example, the checkout action has a post-run step that runs regardless of the success of previous steps, as you can see in this run on my repo. What I'd like is for there to be a setting such that the same behavior can happen for the cache action.

kylrth avatar Aug 10 '22 17:08 kylrth

@kylrth actions/checkout runs for cleanup. If cache was allowed to save cache even on job fail then it could create corrupted cache, in most cases. If there is more request for this feature we would work on this.

Phantsure avatar Aug 17 '22 09:08 Phantsure

I'm pretty sure that there already is more than a request for this feature (https://github.com/actions/cache/issues/92).

jorgemo-fever avatar Aug 17 '22 10:08 jorgemo-fever

Thanks @jorgemo-fever for pointing that. We have internal discussions related to these issues.

Phantsure avatar Aug 17 '22 10:08 Phantsure

I guess I'll close this issue then since it's a duplicate of #92. It's a shame this hasn't been added because there is definitely interest.

kylrth avatar Aug 17 '22 21:08 kylrth

Hey everyone 👋🏽

Two new actions actions/cache/restore and actions/cache/save are now available with tag v3 to everyone for use. These can now be used to achieve granular control on the restore and save steps in the cache action.

Do try them and give your feedback. We believe these new actions will take care of your use cases. 🙇🏽

The save action can be made to run always by passing always() in the if condition.

kotewar avatar Dec 22 '22 06:12 kotewar