mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 08:43:55 +08:00
added ts code
This commit is contained in:
parent
73cb7e0405
commit
54f20c8e9b
4 changed files with 10 additions and 1 deletions
|
@ -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'
|
||||
|
|
|
@ -6,7 +6,8 @@ export enum Inputs {
|
|||
}
|
||||
|
||||
export enum Outputs {
|
||||
CacheHit = "cache-hit"
|
||||
CacheHit = "cache-hit",
|
||||
CacheRestored = "cache-restored"
|
||||
}
|
||||
|
||||
export enum State {
|
||||
|
|
|
@ -52,6 +52,7 @@ async function run(): Promise<void> {
|
|||
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<void> {
|
|||
throw error;
|
||||
} else {
|
||||
utils.logWarning(error.message);
|
||||
utils.setCacheRestoredOutput(false);
|
||||
utils.setCacheHitOutput(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue