mirror of
				https://kkgithub.com/actions/cache.git
				synced 2025-11-01 03:01:50 +08:00 
			
		
		
		
	Merge branch 'main' into kotewar/states-input-provider
This commit is contained in:
		| @ -2,7 +2,8 @@ export enum Inputs { | ||||
|     Key = "key", // Input for cache, restore, save action | ||||
|     Path = "path", // Input for cache, restore, save action | ||||
|     RestoreKeys = "restore-keys", // Input for cache, restore action | ||||
|     UploadChunkSize = "upload-chunk-size" // Input for cache, save action | ||||
|     UploadChunkSize = "upload-chunk-size", // Input for cache, save action | ||||
|     EnableCrossOsArchive = "enableCrossOsArchive" // Input for cache, restore, save action | ||||
| } | ||||
|  | ||||
| export enum Outputs { | ||||
|  | ||||
| @ -31,11 +31,16 @@ async function restoreImpl( | ||||
|         const cachePaths = utils.getInputAsArray(Inputs.Path, { | ||||
|             required: true | ||||
|         }); | ||||
|         const enableCrossOsArchive = utils.getInputAsBool( | ||||
|             Inputs.EnableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         const cacheKey = await cache.restoreCache( | ||||
|             cachePaths, | ||||
|             primaryKey, | ||||
|             restoreKeys | ||||
|             restoreKeys, | ||||
|             {}, | ||||
|             enableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         if (!cacheKey) { | ||||
|  | ||||
| @ -50,9 +50,16 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> { | ||||
|             required: true | ||||
|         }); | ||||
|  | ||||
|         cacheId = await cache.saveCache(cachePaths, primaryKey, { | ||||
|             uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) | ||||
|         }); | ||||
|         const enableCrossOsArchive = utils.getInputAsBool( | ||||
|             Inputs.EnableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         cacheId = await cache.saveCache( | ||||
|             cachePaths, | ||||
|             primaryKey, | ||||
|             { uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) }, | ||||
|             enableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         if (cacheId != -1) { | ||||
|             core.info(`Cache saved with key: ${primaryKey}`); | ||||
|  | ||||
| @ -52,6 +52,14 @@ export function getInputAsInt( | ||||
|     return value; | ||||
| } | ||||
|  | ||||
| export function getInputAsBool( | ||||
|     name: string, | ||||
|     options?: core.InputOptions | ||||
| ): boolean { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
|  | ||||
| export function isCacheFeatureAvailable(): boolean { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
|  | ||||
| @ -17,6 +17,7 @@ interface CacheInput { | ||||
|     path: string; | ||||
|     key: string; | ||||
|     restoreKeys?: string[]; | ||||
|     enableCrossOsArchive?: boolean; | ||||
| } | ||||
|  | ||||
| export function setInputs(input: CacheInput): void { | ||||
| @ -24,6 +25,11 @@ export function setInputs(input: CacheInput): void { | ||||
|     setInput(Inputs.Key, input.key); | ||||
|     input.restoreKeys && | ||||
|         setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n")); | ||||
|     input.enableCrossOsArchive !== undefined && | ||||
|         setInput( | ||||
|             Inputs.EnableCrossOsArchive, | ||||
|             input.enableCrossOsArchive.toString() | ||||
|         ); | ||||
| } | ||||
|  | ||||
| export function clearInputs(): void { | ||||
| @ -31,4 +37,5 @@ export function clearInputs(): void { | ||||
|     delete process.env[getInputName(Inputs.Key)]; | ||||
|     delete process.env[getInputName(Inputs.RestoreKeys)]; | ||||
|     delete process.env[getInputName(Inputs.UploadChunkSize)]; | ||||
|     delete process.env[getInputName(Inputs.EnableCrossOsArchive)]; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sankalp Kotewar
					Sankalp Kotewar