Added logic fo saving cache on any failure

This commit is contained in:
Sankalp Kotewar 2022-11-21 08:35:34 +00:00 committed by GitHub
parent d3ebc46a6f
commit 885d768356
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 2 deletions

View file

@ -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 {

View file

@ -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);
}