mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 06:20:55 +00:00 
			
		
		
		
	Add fail-on-cache-miss option
This commit is contained in:
		
					parent
					
						
							
								6fd2d4538c
							
						
					
				
			
			
				commit
				
					
						a5631aba37
					
				
			
		
					 11 changed files with 124 additions and 11 deletions
				
			
		|  | @ -7,6 +7,7 @@ The restore action, as the name suggest, restores a cache. It acts similar to th | |||
| * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. | ||||
| * `key` - String used while saving cache for restoring the cache | ||||
| * `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. | ||||
| * `fail-on-cache-miss` - Fail the workflow if the cache is not found for the primary key | ||||
| 
 | ||||
| ## Outputs | ||||
| 
 | ||||
|  | @ -95,7 +96,7 @@ steps: | |||
| 
 | ||||
| ### Exit workflow on cache miss | ||||
| 
 | ||||
| You can use the output of this action to exit the workflow on cache miss. This way you can restrict your workflow to only initiate the build when `cache-hit` occurs, in other words, cache with exact key is found. | ||||
| You can use `fail-on-cache-miss: true` to exit the workflow on a cache miss. This way you can restrict your workflow to only initiate the build when a cache with the exact key is found. | ||||
| 
 | ||||
| ```yaml | ||||
| steps: | ||||
|  | @ -106,10 +107,7 @@ steps: | |||
|     with: | ||||
|       path: path/to/dependencies | ||||
|       key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} | ||||
| 
 | ||||
|   - name: Check cache hit | ||||
|     if: steps.cache.outputs.cache-hit != 'true' | ||||
|     run: exit 1 | ||||
|       fail-on-cache-miss: true | ||||
| 
 | ||||
|   - name: Build | ||||
|     run: /build.sh | ||||
|  |  | |||
|  | @ -15,6 +15,10 @@ inputs: | |||
|     description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms' | ||||
|     default: 'false' | ||||
|     required: false | ||||
|   fail-on-cache-miss: | ||||
|     description: 'Fail the workflow if the cache is not found for the primary key' | ||||
|     required: false | ||||
|     default: "false" | ||||
| outputs: | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate an exact match was found for the primary key' | ||||
|  | @ -27,4 +31,4 @@ runs: | |||
|   main: '../dist/restore-only/index.js' | ||||
| branding: | ||||
|   icon: 'archive' | ||||
|   color: 'gray-dark' | ||||
|   color: 'gray-dark' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue