mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-06-18 01:31:11 +00:00
resave primary key to state if reeval is true & get state afterward
This commit is contained in:
parent
9840f83c99
commit
3d5818e554
2 changed files with 7 additions and 5 deletions
|
@ -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.`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue