Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to actions/cache to not save conditionally #1493

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add option to cache action to not save
  • Loading branch information
EnricoMi committed Nov 4, 2024
commit 3f0646840edee93389c02eae5d2e4b78a01fef82
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ inputs:
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
default: 'false'
required: false
save:
description: 'Do not run the post step to save the cache if false'
default: 'true'
required: false
save-always:
description: 'Run the post step to save the cache even if another step before fails'
default: 'false'
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@ export enum Inputs {
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
LookupOnly = "lookup-only" // Input for cache, restore action
LookupOnly = "lookup-only", // Input for cache, restore action
Save = "save" // Input for save action
}

export enum Outputs {
8 changes: 7 additions & 1 deletion src/save.ts
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test-dont-save jobs shows that this is not sufficient to skip the post job if save: false. Pointers to the right place to add the if (doSave) appreciated.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import * as core from "@actions/core";

import { Inputs } from "./constants";
import { saveRun } from "./saveImpl";

saveRun(true);
const doSave = core.getInput(Inputs.Save);
if (doSave) {
saveRun(true);
}