Add option to cache action to not save

This commit is contained in:
Enrico Minack 2024-11-04 18:23:58 +01:00
parent 6849a64899
commit 3f0646840e
4 changed files with 15 additions and 4 deletions

View file

@ -26,6 +26,10 @@ inputs:
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache' description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
default: 'false' default: 'false'
required: false required: false
save:
description: 'Do not run the post step to save the cache if false'
default: 'true'
required: false
save-always: save-always:
description: 'Run the post step to save the cache even if another step before fails' description: 'Run the post step to save the cache even if another step before fails'
default: 'false' default: 'false'

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "cache", "name": "cache",
"version": "4.1.1", "version": "4.1.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cache", "name": "cache",
"version": "4.1.1", "version": "4.1.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.2.3", "@actions/cache": "^3.2.3",

View file

@ -5,7 +5,8 @@ export enum Inputs {
UploadChunkSize = "upload-chunk-size", // Input for cache, save action UploadChunkSize = "upload-chunk-size", // Input for cache, save action
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore 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 { export enum Outputs {

View file

@ -1,3 +1,9 @@
import * as core from "@actions/core";
import { Inputs } from "./constants";
import { saveRun } from "./saveImpl"; import { saveRun } from "./saveImpl";
saveRun(true); const doSave = core.getInput(Inputs.Save);
if (doSave) {
saveRun(true);
}