mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 10:14:02 +00:00 
			
		
		
		
	added ts code
This commit is contained in:
		
							parent
							
								
									73cb7e0405
								
							
						
					
					
						commit
						54f20c8e9b
					
				@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user