From 3d5818e5549145f483496693ba1f18f99edd54bb Mon Sep 17 00:00:00 2001 From: Vincent Clemson Date: Sun, 19 Jun 2022 03:13:39 -0400 Subject: [PATCH] resave primary key to state if reeval is true & get state afterward --- dist/save/index.js | 5 +++-- src/save.ts | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/save/index.js b/dist/save/index.js index e3153a0..4d7e109 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -46782,7 +46782,6 @@ function run() { utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`); return; } - const state = utils.getCacheState(); let primaryKey = ""; const reeval = core.getBooleanInput(constants_1.Inputs.Reeval); if (!reeval) { @@ -46790,13 +46789,15 @@ function run() { primaryKey = core.getState(constants_1.State.CachePrimaryKey); } else { - // choose to reevaluate primary key + // choose to reevaluate primary key - resave state to correctly test cache hit primaryKey = core.getInput(constants_1.Inputs.Key, { required: true }); + core.saveState(constants_1.State.CachePrimaryKey, primaryKey); } if (!primaryKey) { utils.logWarning(`Error retrieving key from state.`); return; } + const state = utils.getCacheState(); if (utils.isExactKeyMatch(primaryKey, state)) { core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); return; diff --git a/src/save.ts b/src/save.ts index df2fe4a..1dfd059 100644 --- a/src/save.ts +++ b/src/save.ts @@ -26,22 +26,23 @@ async function run(): Promise { return; } - const state = utils.getCacheState(); - let primaryKey = ""; const reeval = core.getBooleanInput(Inputs.Reeval); if (!reeval) { // Inputs are reevaluted before the post action, so we want the original key used for restore primaryKey = core.getState(State.CachePrimaryKey); } else { - // choose to reevaluate primary key + // choose to reevaluate primary key - resave state to correctly test cache hit primaryKey = core.getInput(Inputs.Key, { required: true }); + core.saveState(State.CachePrimaryKey, primaryKey); } if (!primaryKey) { utils.logWarning(`Error retrieving key from state.`); return; } + const state = utils.getCacheState(); + if (utils.isExactKeyMatch(primaryKey, state)) { core.info( `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`