From f0a29e5cc90533526a3edfc2f2a22dae0102d30b Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Fri, 5 Nov 2021 16:19:11 +0100 Subject: [PATCH 1/2] Add option to re-evaluate cache key during post action --- README.md | 1 + action.yml | 4 ++++ src/constants.ts | 3 ++- src/saveImpl.ts | 6 +++--- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f07f15..84bbc93 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir * `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false` * `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false` * `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false` +* `reeval-key` - A boolean which causes the key to be re-evaluated during the Post-Action step #### Environment Variables diff --git a/action.yml b/action.yml index 7af7458..14a5a8b 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: save-always does not work as intended and will be removed in a future release. A separate `actions/cache/restore` step should be used instead. See https://github.com/actions/cache/tree/main/save#always-save-cache for more details. + reeval-key: + description: 'Re-evaluate the cache key during the post-action' + required: false + default: false outputs: cache-hit: description: 'A boolean value to indicate an exact match was found for the primary key' diff --git a/src/constants.ts b/src/constants.ts index 0158ae0..d90cfc3 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 + ReEvalKey = "reeval-key" } export enum Outputs { diff --git a/src/saveImpl.ts b/src/saveImpl.ts index 4e5c312..fb70a34 100644 --- a/src/saveImpl.ts +++ b/src/saveImpl.ts @@ -34,9 +34,9 @@ export async function saveImpl( // If restore has stored a primary key in state, reuse that // Else re-evaluate from inputs - const primaryKey = - stateProvider.getState(State.CachePrimaryKey) || - core.getInput(Inputs.Key); + const primaryKey = core.getBooleanInput(Inputs.ReEvalKey) + ? core.getInput(Inputs.Key) + : (stateProvider.getState(State.CachePrimaryKey) || core.getInput(Inputs.Key)); if (!primaryKey) { utils.logWarning(`Key is not specified.`); From 4598e54d46dd76654c13595dba197d2125986a3f Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Tue, 15 Apr 2025 20:05:59 +0200 Subject: [PATCH 2/2] Update dist --- dist/restore-only/index.js | 3 ++- dist/restore/index.js | 3 ++- dist/save-only/index.js | 8 +++++--- dist/save/index.js | 8 +++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index c42c938..69f06b6 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -64911,7 +64911,8 @@ var Inputs; Inputs["UploadChunkSize"] = "upload-chunk-size"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; - Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action + Inputs["LookupOnly"] = "lookup-only"; + Inputs["ReEvalKey"] = "reeval-key"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { diff --git a/dist/restore/index.js b/dist/restore/index.js index 95f7849..b241cd6 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -64911,7 +64911,8 @@ var Inputs; Inputs["UploadChunkSize"] = "upload-chunk-size"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; - Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action + Inputs["LookupOnly"] = "lookup-only"; + Inputs["ReEvalKey"] = "reeval-key"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { diff --git a/dist/save-only/index.js b/dist/save-only/index.js index 1e1b222..1cbb51d 100644 --- a/dist/save-only/index.js +++ b/dist/save-only/index.js @@ -64911,7 +64911,8 @@ var Inputs; Inputs["UploadChunkSize"] = "upload-chunk-size"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; - Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action + Inputs["LookupOnly"] = "lookup-only"; + Inputs["ReEvalKey"] = "reeval-key"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { @@ -64996,8 +64997,9 @@ function saveImpl(stateProvider) { } // If restore has stored a primary key in state, reuse that // Else re-evaluate from inputs - const primaryKey = stateProvider.getState(constants_1.State.CachePrimaryKey) || - core.getInput(constants_1.Inputs.Key); + const primaryKey = core.getBooleanInput(constants_1.Inputs.ReEvalKey) + ? core.getInput(constants_1.Inputs.Key) + : (stateProvider.getState(constants_1.State.CachePrimaryKey) || core.getInput(constants_1.Inputs.Key)); if (!primaryKey) { utils.logWarning(`Key is not specified.`); return; diff --git a/dist/save/index.js b/dist/save/index.js index d288e0b..d4f3c90 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -64911,7 +64911,8 @@ var Inputs; Inputs["UploadChunkSize"] = "upload-chunk-size"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; - Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action + Inputs["LookupOnly"] = "lookup-only"; + Inputs["ReEvalKey"] = "reeval-key"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { @@ -64996,8 +64997,9 @@ function saveImpl(stateProvider) { } // If restore has stored a primary key in state, reuse that // Else re-evaluate from inputs - const primaryKey = stateProvider.getState(constants_1.State.CachePrimaryKey) || - core.getInput(constants_1.Inputs.Key); + const primaryKey = core.getBooleanInput(constants_1.Inputs.ReEvalKey) + ? core.getInput(constants_1.Inputs.Key) + : (stateProvider.getState(constants_1.State.CachePrimaryKey) || core.getInput(constants_1.Inputs.Key)); if (!primaryKey) { utils.logWarning(`Key is not specified.`); return;