Use cachePathList to iterate over multiple cache paths

Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
This commit is contained in:
Kipras Melnikovas 2020-02-07 01:26:30 +02:00
parent 9a9c8d77fd
commit 197962b975
No known key found for this signature in database
GPG key ID: AA505BC1C6D8AD90

View file

@ -56,30 +56,32 @@ async function run(): Promise<void> {
cachePathList = [cachePath, ...cachePathList];
core.debug(`Cache Path: ${cachePath}`);
for (const cachePath of cachePathList) {
core.debug(`Cache Path: ${cachePath}`);
const archivePath = path.join(
await utils.createTempDirectory(),
"cache.tgz"
);
core.debug(`Archive Path: ${archivePath}`);
await createTar(archivePath, cachePath);
const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
const archiveFileSize = utils.getArchiveFileSize(archivePath);
core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) {
utils.logWarning(
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`
const archivePath = path.join(
await utils.createTempDirectory(),
"cache.tgz"
);
return;
}
core.debug(`Archive Path: ${archivePath}`);
core.debug(`Saving Cache (ID: ${cacheId})`);
await cacheHttpClient.saveCache(cacheId, archivePath);
await createTar(archivePath, cachePath);
const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
const archiveFileSize = utils.getArchiveFileSize(archivePath);
core.debug(`File Size: ${archiveFileSize}`);
if (archiveFileSize > fileSizeLimit) {
utils.logWarning(
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`
);
return;
}
core.debug(`Saving Cache (ID: ${cacheId})`);
await cacheHttpClient.saveCache(cacheId, archivePath);
}
} catch (error) {
utils.logWarning(error.message);
}