mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-20 11:46:22 +02:00
Use cachePathList
to iterate over multiple cache paths
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
This commit is contained in:
parent
9a9c8d77fd
commit
197962b975
1 changed files with 23 additions and 21 deletions
44
src/save.ts
44
src/save.ts
|
@ -56,30 +56,32 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
cachePathList = [cachePath, ...cachePathList];
|
cachePathList = [cachePath, ...cachePathList];
|
||||||
|
|
||||||
core.debug(`Cache Path: ${cachePath}`);
|
for (const cachePath of cachePathList) {
|
||||||
|
core.debug(`Cache Path: ${cachePath}`);
|
||||||
|
|
||||||
const archivePath = path.join(
|
const archivePath = path.join(
|
||||||
await utils.createTempDirectory(),
|
await utils.createTempDirectory(),
|
||||||
"cache.tgz"
|
"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.`
|
|
||||||
);
|
);
|
||||||
return;
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
await createTar(archivePath, cachePath);
|
||||||
await cacheHttpClient.saveCache(cacheId, archivePath);
|
|
||||||
|
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) {
|
} catch (error) {
|
||||||
utils.logWarning(error.message);
|
utils.logWarning(error.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue