diff --git a/package.json b/package.json index 78ec707..7af2581 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "0.3.0", + "version": "0.4.0", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", diff --git a/src/cache.service.ts b/src/cache.service.ts index 65365e3..c60f8d6 100644 --- a/src/cache.service.ts +++ b/src/cache.service.ts @@ -36,6 +36,8 @@ export class CacheService { } async saveCache(paths: string[], key: string): Promise { + const cacheId: string = this.getCacheId(key); + const compressionMethod = await utils.getCompressionMethod(); const cachePaths = await utils.resolvePaths(paths); @@ -60,8 +62,8 @@ export class CacheService { `Archive Size: ${filesize(fs.statSync(archivePath).size)}` ); - core.debug(`Saving Cache (ID: ${key})`); - await this.uploadToS3(key, archivePath); + core.debug(`Saving Cache (ID: ${cacheId})`); + await this.uploadToS3(cacheId, archivePath); } finally { // Try to delete the archive to save space try { @@ -89,4 +91,10 @@ export class CacheService { }) .promise(); } + + private getCacheId(primaryKey: string): string { + return `${process.env["GITHUB_REPOSITORY"] + ?.replace("/", "-") + .toLowerCase()}-${primaryKey}`; + } }