diff --git a/action.yml b/action.yml index b5460b7..a402bc4 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,8 @@ inputs: outputs: cache-hit: description: 'A boolean value to indicate an exact match was found for the primary key' + cache-restored: + description: 'A boolean value to indicate an exact or partial match was found resulting in a restore' runs: using: 'node16' main: 'dist/restore/index.js' diff --git a/src/constants.ts b/src/constants.ts index 133f47d..7538781 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,7 +6,8 @@ export enum Inputs { } export enum Outputs { - CacheHit = "cache-hit" + CacheHit = "cache-hit", + CacheRestored = "cache-restored" } export enum State { diff --git a/src/restore.ts b/src/restore.ts index d411459..db9a9f7 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -52,6 +52,7 @@ async function run(): Promise { utils.setCacheState(cacheKey); const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); + utils.setCacheRestoredOutput(true); utils.setCacheHitOutput(isExactKeyMatch); core.info(`Cache restored from key: ${cacheKey}`); @@ -60,6 +61,7 @@ async function run(): Promise { throw error; } else { utils.logWarning(error.message); + utils.setCacheRestoredOutput(false); utils.setCacheHitOutput(false); } } diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index a4d712d..361afb7 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -26,6 +26,10 @@ export function setCacheHitOutput(isCacheHit: boolean): void { core.setOutput(Outputs.CacheHit, isCacheHit.toString()); } +export function setCacheRestoredOutput(isCacheRestored: boolean): void { + core.setOutput(Outputs.CacheRestored, isCacheRestored.toString()); +} + export function setOutputAndState(key: string, cacheKey?: string): void { setCacheHitOutput(isExactKeyMatch(key, cacheKey)); // Store the matched cache key if it exists