mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 17:23:59 +08:00
Saving state early to take care of all cases
This commit is contained in:
parent
8c4782cf33
commit
91d3f2deb0
2 changed files with 15 additions and 14 deletions
|
@ -35,6 +35,15 @@ async function run(): Promise<void> {
|
|||
restoreKeys
|
||||
);
|
||||
|
||||
//Check if user wants to save cache despite of failure in any previous job
|
||||
const saveCache = core.getInput(Inputs.SaveCacheOnAnyFailure);
|
||||
if (saveCache === "yes") {
|
||||
core.saveState(State.SaveCache, saveCache);
|
||||
core.info(
|
||||
`Input save-cache-on-any-failure is set to yes, the cache will be saved despite of any failure in the build.`
|
||||
);
|
||||
}
|
||||
|
||||
if (!cacheKey) {
|
||||
if (core.getInput(Inputs.StrictRestore) == "true") {
|
||||
throw new Error(
|
||||
|
@ -63,15 +72,6 @@ async function run(): Promise<void> {
|
|||
);
|
||||
}
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
|
||||
const saveCache = core.getInput(Inputs.SaveCacheOnAnyFailure);
|
||||
|
||||
if (saveCache === "yes") {
|
||||
core.saveState(State.SaveCache, saveCache);
|
||||
core.info(
|
||||
`Input save-cache-on-any-failure is set to yes, the cache will be saved despite of any failure in the build.`
|
||||
);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
core.setFailed((error as Error).message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue