mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 17:23:59 +08:00
Added logic fo saving cache on any failure
This commit is contained in:
parent
d3ebc46a6f
commit
885d768356
4 changed files with 22 additions and 2 deletions
|
@ -3,7 +3,8 @@ export enum Inputs {
|
|||
Path = "path",
|
||||
RestoreKeys = "restore-keys",
|
||||
UploadChunkSize = "upload-chunk-size",
|
||||
StrictRestore = "strict-restore"
|
||||
StrictRestore = "strict-restore",
|
||||
SaveCacheOnAnyFailure = "save-cache-on-any-failure"
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
|
@ -12,7 +13,8 @@ export enum Outputs {
|
|||
|
||||
export enum State {
|
||||
CachePrimaryKey = "CACHE_KEY",
|
||||
CacheMatchedKey = "CACHE_RESULT"
|
||||
CacheMatchedKey = "CACHE_RESULT",
|
||||
SaveCache = "SAVE_CACHE"
|
||||
}
|
||||
|
||||
export enum Events {
|
||||
|
|
|
@ -63,6 +63,15 @@ 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