mirror of
https://github.com/actions/cache.git
synced 2025-07-19 21:35:15 -06:00
feat: force-update
This commit is contained in:
parent
c7c46bcb6d
commit
17151cf67e
4 changed files with 37 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
export enum Inputs {
|
||||
ForceUpdate = "force-update",
|
||||
Key = "key",
|
||||
Path = "path",
|
||||
RestoreKeys = "restore-keys",
|
||||
|
|
|
@ -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.`
|
||||
);
|
||||
|
|
|
@ -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)];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue