This commit is contained in:
Caleb Gosiak 2021-09-30 16:12:55 -05:00
parent 2377d067bc
commit a51ff9983a
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "cache", "name": "cache",
"version": "0.3.0", "version": "0.4.0",
"private": true, "private": true,
"description": "Cache dependencies and build outputs", "description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js", "main": "dist/restore/index.js",

View file

@ -36,6 +36,8 @@ export class CacheService {
} }
async saveCache(paths: string[], key: string): Promise<string> { async saveCache(paths: string[], key: string): Promise<string> {
const cacheId: string = this.getCacheId(key);
const compressionMethod = await utils.getCompressionMethod(); const compressionMethod = await utils.getCompressionMethod();
const cachePaths = await utils.resolvePaths(paths); const cachePaths = await utils.resolvePaths(paths);
@ -60,8 +62,8 @@ export class CacheService {
`Archive Size: ${filesize(fs.statSync(archivePath).size)}` `Archive Size: ${filesize(fs.statSync(archivePath).size)}`
); );
core.debug(`Saving Cache (ID: ${key})`); core.debug(`Saving Cache (ID: ${cacheId})`);
await this.uploadToS3(key, archivePath); await this.uploadToS3(cacheId, archivePath);
} finally { } finally {
// Try to delete the archive to save space // Try to delete the archive to save space
try { try {
@ -89,4 +91,10 @@ export class CacheService {
}) })
.promise(); .promise();
} }
private getCacheId(primaryKey: string): string {
return `${process.env["GITHUB_REPOSITORY"]
?.replace("/", "-")
.toLowerCase()}-${primaryKey}`;
}
} }