feat: force-update

This commit is contained in:
Dulmandakh 2022-03-07 23:43:23 +08:00
parent c7c46bcb6d
commit 17151cf67e
4 changed files with 37 additions and 3 deletions

View file

@ -1,4 +1,5 @@
export enum Inputs {
ForceUpdate = "force-update",
Key = "key",
Path = "path",
RestoreKeys = "restore-keys",

View file

@ -27,8 +27,6 @@ async function run(): Promise<void> {
return;
}
const state = utils.getCacheState();
// Inputs are re-evaluted before the post action, so we want the original key used for restore
const primaryKey = core.getState(State.CachePrimaryKey);
if (!primaryKey) {
@ -36,7 +34,9 @@ async function run(): Promise<void> {
return;
}
if (utils.isExactKeyMatch(primaryKey, state)) {
const forceUpdate = core.getInput(Inputs.ForceUpdate) === "true";
const state = utils.getCacheState();
if (utils.isExactKeyMatch(primaryKey, state) && !forceUpdate) {
core.info(
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
);

View file

@ -23,6 +23,7 @@ export function setInputs(input: CacheInput): void {
}
export function clearInputs(): void {
delete process.env[getInputName(Inputs.ForceUpdate)];
delete process.env[getInputName(Inputs.Path)];
delete process.env[getInputName(Inputs.Key)];
delete process.env[getInputName(Inputs.RestoreKeys)];