mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 10:14:02 +00:00 
			
		
		
		
	Strict restore implemented
This commit is contained in:
		
							parent
							
								
									dde24d199d
								
							
						
					
					
						commit
						7924423105
					
				@ -12,6 +12,9 @@ inputs:
 | 
			
		||||
  restore-keys:
 | 
			
		||||
    description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.'
 | 
			
		||||
    required: false
 | 
			
		||||
  strict-restore:
 | 
			
		||||
    description: 'Fail the workflow if the cache is not found for the given key.'
 | 
			
		||||
    required: false
 | 
			
		||||
outputs:
 | 
			
		||||
  cache-hit:
 | 
			
		||||
    description: 'A boolean value to indicate an exact match was found for the primary key'
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,8 @@ export enum Inputs {
 | 
			
		||||
    Key = "key",
 | 
			
		||||
    Path = "path",
 | 
			
		||||
    RestoreKeys = "restore-keys",
 | 
			
		||||
    UploadChunkSize = "upload-chunk-size"
 | 
			
		||||
    UploadChunkSize = "upload-chunk-size",
 | 
			
		||||
    StrictRestore = "strict-restore"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum Outputs {
 | 
			
		||||
 | 
			
		||||
@ -51,6 +51,13 @@ async function run(): Promise<void> {
 | 
			
		||||
 | 
			
		||||
        const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
 | 
			
		||||
        utils.setCacheHitOutput(isExactKeyMatch);
 | 
			
		||||
 | 
			
		||||
        if (!isExactKeyMatch && core.getInput(Inputs.StrictRestore) == "true") {
 | 
			
		||||
            core.info(
 | 
			
		||||
                "Cache with exact key not found, hence exiting the workflow as strict-restore is set to true"
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        core.info(`Cache restored from key: ${cacheKey}`);
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        core.setFailed((error as Error).message);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user