reproducible-containers / buildkit-cache-dance

Save `RUN --mount=type=cache` caches on GitHub Actions ( Forked from https://github.com/overmindtech/buildkit-cache-dance )
Apache License 2.0
143 stars 29 forks source link

Do not extract cache on job failure #32

Closed borchero closed 4 months ago

borchero commented 4 months ago

Motivation

Currently, the cache is always extracted from the build. This is likely unnecessary if the build fails.

This PR skips the extraction step if the workflow job fails unless the new save-always input parameter is set to true. This mirrors the behavior of the official actions/cache action which, by default, does not upload the cache if the workflow job fails.

The current set of inputs does not allow to replicate this behavior: skip-extraction cannot be used since success() or failure() cannot look ahead (and cannot be used for action inputs).

Note: This change is breaking as it changes previous behavior. This could be prevented by using a different approach than actions/cache and having the user explicitly set skip-extraction-on-failure: true, changing the post-if condition to success() || github.event.inputs.skip-extraction-on-failure == 'false'. I would personally prefer the change in this PR though as it seems more logical.

borchero commented 4 months ago

Thanks for merging so quickly @AkihiroSuda! Any chance this can be included in a new release? :pray:

AkihiroSuda commented 4 months ago

Done https://github.com/reproducible-containers/buildkit-cache-dance/releases/tag/v3.1.1