Deploy version 1.0.0
This commit is contained in:
@@ -12,6 +12,10 @@ inputs:
|
||||
paths:
|
||||
description: "List of paths to cache"
|
||||
required: true
|
||||
cmprss:
|
||||
description: "Compression level for the cache. ZStd, eg. 0-6"
|
||||
required: false
|
||||
default: "3"
|
||||
|
||||
runs:
|
||||
using: "node20"
|
||||
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@@ -33995,7 +33995,7 @@ function formatSize(bytes) {
|
||||
|
||||
// src/save.ts
|
||||
var execFileAsync = (0, import_util.promisify)(import_child_process.execFile);
|
||||
async function saveCache(key, paths) {
|
||||
async function saveCache(key, paths, cmprss_lvl = 3) {
|
||||
const tempDir = await fs13.promises.mkdtemp("/tmp/cache-save-");
|
||||
const tarPath = path8.join(tempDir, "cache.tar");
|
||||
const zstPath = path8.join(tempDir, "cache.tar.zst");
|
||||
@@ -34018,9 +34018,14 @@ async function saveCache(key, paths) {
|
||||
core.info(
|
||||
`Tar archive created in ${durationInSeconds} seconds (${formatSize(tarSize)})`
|
||||
);
|
||||
core.info(`Compressing archive to zstd: ${zstPath}`);
|
||||
core.info(`Compressing archive to zstd (Level: ${cmprss_lvl}): ${zstPath}`);
|
||||
startTime = Date.now();
|
||||
await execFileAsync("zstd", ["-3", "-o", zstPath, tarPath]);
|
||||
await execFileAsync("zstd", [
|
||||
"-" + cmprss_lvl.toString(),
|
||||
"-o",
|
||||
zstPath,
|
||||
tarPath
|
||||
]);
|
||||
endTime = Date.now();
|
||||
duration = endTime - startTime;
|
||||
durationInSeconds = (duration / 1e3).toFixed(2);
|
||||
@@ -34107,22 +34112,34 @@ async function run() {
|
||||
core3.info("Post-job: Saving cache...");
|
||||
const key = core3.getState("key");
|
||||
const paths = JSON.parse(core3.getState("paths") || "[]");
|
||||
const cmprss_lvl = parseInt(
|
||||
core3.getState("compression-level") || "3",
|
||||
10
|
||||
);
|
||||
if (!key) {
|
||||
throw new Error("State 'key' not found during Post-Job.");
|
||||
}
|
||||
if (paths.length === 0) {
|
||||
throw new Error("State 'paths' not found or empty during Post-Job.");
|
||||
}
|
||||
await saveCache(key, paths);
|
||||
await saveCache(key, paths, cmprss_lvl);
|
||||
} else {
|
||||
core3.info("Pre-job: Restoring cache...");
|
||||
const key = core3.getInput("key", { required: true });
|
||||
const paths = core3.getMultilineInput("paths", { required: true }).filter(
|
||||
(p) => p.trim() !== ""
|
||||
);
|
||||
let cmprss_lvl = parseInt(
|
||||
core3.getInput("compression-level", { required: false }) || "3",
|
||||
10
|
||||
);
|
||||
if (isNaN(cmprss_lvl) || cmprss_lvl < 0 || cmprss_lvl > 6) {
|
||||
cmprss_lvl = 3;
|
||||
}
|
||||
core3.saveState("isPost", "true");
|
||||
core3.saveState("key", key);
|
||||
core3.saveState("paths", JSON.stringify(paths));
|
||||
core3.saveState("compression-level", cmprss_lvl.toString());
|
||||
const restored = await restoreCache(key);
|
||||
core3.setOutput("cache-hit", restored ? "true" : "false");
|
||||
}
|
||||
|
Reference in New Issue
Block a user