Add cache upload options and pull from latest actions/cache master

This commit is contained in:
Aiqiao Yan
2020-05-12 12:37:03 -04:00
parent c534ad2cbd
commit 1413cd0e32
7 changed files with 309 additions and 67 deletions

View File

@@ -3,6 +3,7 @@ import * as path from 'path'
import * as utils from './internal/cacheUtils'
import * as cacheHttpClient from './internal/cacheHttpClient'
import {createTar, extractTar} from './internal/tar'
import {UploadOptions} from './options'
function checkPaths(paths: string[]): void {
if (!paths || paths.length === 0) {
@@ -102,9 +103,14 @@ export async function restoreCache(
*
* @param paths a list of file paths to be cached
* @param key an explicit key for restoring the cache
* @param options cache upload options
* @returns number returns cacheId if the cache was saved successfully
*/
export async function saveCache(paths: string[], key: string): Promise<number> {
export async function saveCache(
paths: string[],
key: string,
options?: UploadOptions
): Promise<number> {
checkPaths(paths)
checkKey(key)
@@ -147,7 +153,7 @@ export async function saveCache(paths: string[], key: string): Promise<number> {
}
core.debug(`Saving Cache (ID: ${cacheId})`)
await cacheHttpClient.saveCache(cacheId, archivePath)
await cacheHttpClient.saveCache(cacheId, archivePath, options)
return cacheId
}