Skip to content

Commit ecee04e

Browse files
authored
feat: add save-if option, closes #66 (#91)
1 parent b894d59 commit ecee04e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ sensible defaults.
5353
# Determines if the cache should be saved even when the workflow has failed.
5454
# default: "false"
5555
cache-on-failure: ""
56+
57+
# Determiners whether the cache should be saved.
58+
# If `false`, the cache is only restored.
59+
# Useful for jobs where the matrix is additive e.g. additional Cargo features.
60+
# default: "true"
61+
save-if: ""
5662
```
5763
5864
Further examples are available in the [.github/workflows](./.github/workflows/) directory.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
cache-on-failure:
2929
description: "Cache even if the build fails. Defaults to false."
3030
required: false
31+
save-if:
32+
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
33+
required: false
34+
default: "true"
3135
outputs:
3236
cache-hit:
3337
description: "A boolean value that indicates an exact match was found."

src/save.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ process.on("uncaughtException", (e) => {
1313
});
1414

1515
async function run() {
16-
if (!cache.isFeatureAvailable()) {
16+
const save = core.getInput("save-if").toLowerCase() || "true";
17+
18+
if (!(cache.isFeatureAvailable() && save === "true")) {
1719
return;
1820
}
1921

0 commit comments

Comments
 (0)