From 3f0646840edee93389c02eae5d2e4b78a01fef82 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Mon, 4 Nov 2024 18:23:58 +0100 Subject: [PATCH] Add option to cache action to not save --- action.yml | 4 ++++ package-lock.json | 4 ++-- src/constants.ts | 3 ++- src/save.ts | 8 +++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 7af7458..86b6d2d 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/package-lock.json b/package-lock.json index b3e6311..fddd60a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cache", - "version": "4.1.1", + "version": "4.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cache", - "version": "4.1.1", + "version": "4.1.2", "license": "MIT", "dependencies": { "@actions/cache": "^3.2.3", diff --git a/src/constants.ts b/src/constants.ts index 0158ae0..f7ce717 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 { diff --git a/src/save.ts b/src/save.ts index 34f7e69..2b95fd1 100644 --- a/src/save.ts +++ b/src/save.ts @@ -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); +}