1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-19 11:36:18 +02:00

resave primary key to state if reeval is true & get state afterward

This commit is contained in:
Vincent Clemson 2022-06-19 03:13:39 -04:00
parent 9840f83c99
commit 3d5818e554
2 changed files with 7 additions and 5 deletions

5
dist/save/index.js vendored
View file

@ -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;

View file

@ -26,22 +26,23 @@ async function run(): Promise<void> {
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.`