mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 15:26:24 +07:00 
			
		
		
		
	Consuming 3.0 actions/cache (#834)
* Consuming 3.0 actions/cache * formatting and error * updated package version * resolve package * dist * review comment * dist * dist
This commit is contained in:
		| @ -29,38 +29,29 @@ async function run(): Promise<void> { | ||||
|             required: true | ||||
|         }); | ||||
|  | ||||
|         try { | ||||
|             const cacheKey = await cache.restoreCache( | ||||
|                 cachePaths, | ||||
|                 primaryKey, | ||||
|                 restoreKeys | ||||
|         const cacheKey = await cache.restoreCache( | ||||
|             cachePaths, | ||||
|             primaryKey, | ||||
|             restoreKeys | ||||
|         ); | ||||
|  | ||||
|         if (!cacheKey) { | ||||
|             core.info( | ||||
|                 `Cache not found for input keys: ${[ | ||||
|                     primaryKey, | ||||
|                     ...restoreKeys | ||||
|                 ].join(", ")}` | ||||
|             ); | ||||
|             if (!cacheKey) { | ||||
|                 core.info( | ||||
|                     `Cache not found for input keys: ${[ | ||||
|                         primaryKey, | ||||
|                         ...restoreKeys | ||||
|                     ].join(", ")}` | ||||
|                 ); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             // Store the matched cache key | ||||
|             utils.setCacheState(cacheKey); | ||||
|  | ||||
|             const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); | ||||
|             utils.setCacheHitOutput(isExactKeyMatch); | ||||
|  | ||||
|             core.info(`Cache restored from key: ${cacheKey}`); | ||||
|         } catch (error: unknown) { | ||||
|             const typedError = error as Error; | ||||
|             if (typedError.name === cache.ValidationError.name) { | ||||
|                 throw error; | ||||
|             } else { | ||||
|                 utils.logWarning(typedError.message); | ||||
|                 utils.setCacheHitOutput(false); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         // Store the matched cache key | ||||
|         utils.setCacheState(cacheKey); | ||||
|  | ||||
|         const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); | ||||
|         utils.setCacheHitOutput(isExactKeyMatch); | ||||
|         core.info(`Cache restored from key: ${cacheKey}`); | ||||
|     } catch (error: unknown) { | ||||
|         core.setFailed((error as Error).message); | ||||
|     } | ||||
|  | ||||
							
								
								
									
										18
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/save.ts
									
									
									
									
									
								
							| @ -44,20 +44,12 @@ async function run(): Promise<void> { | ||||
|             required: true | ||||
|         }); | ||||
|  | ||||
|         try { | ||||
|             await cache.saveCache(cachePaths, primaryKey, { | ||||
|                 uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) | ||||
|             }); | ||||
|         const cacheId = await cache.saveCache(cachePaths, primaryKey, { | ||||
|             uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) | ||||
|         }); | ||||
|  | ||||
|         if (cacheId != -1) { | ||||
|             core.info(`Cache saved with key: ${primaryKey}`); | ||||
|         } catch (error: unknown) { | ||||
|             const typedError = error as Error; | ||||
|             if (typedError.name === cache.ValidationError.name) { | ||||
|                 throw error; | ||||
|             } else if (typedError.name === cache.ReserveCacheError.name) { | ||||
|                 core.info(typedError.message); | ||||
|             } else { | ||||
|                 utils.logWarning(typedError.message); | ||||
|             } | ||||
|         } | ||||
|     } catch (error: unknown) { | ||||
|         utils.logWarning((error as Error).message); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shubham Tiwari
					Shubham Tiwari