Deploy version 1.2.0

This commit is contained in:
Gitea Actions
2025-05-23 17:10:14 +00:00
parent 0c690c30a2
commit 4f061d73ca
2 changed files with 33 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
name: "MinIO Cache"
description: "Save and restore caches via MinIO/S3."
description: "Save and restore caches"
author: "0xMax42"
branding:
icon: "archive"
@@ -15,7 +15,7 @@ inputs:
compression-level:
description: "Compression level for the cache. ZStd, eg. 0-6"
required: false
default: "3"
default: "0"
outputs:
cache-hit:

37
dist/index.js vendored
View File

@@ -26320,16 +26320,20 @@ var fs3 = __toESM(require("fs"));
var path2 = __toESM(require("path"));
var os2 = __toESM(require("os"));
var execAsync = (0, import_util2.promisify)(import_child_process.exec);
async function createCompressedTar(key, paths, cmprss_lvl = 3) {
async function createCompressedTar(key, paths, cmprss_lvl = 0) {
if (!paths || paths.length === 0) {
throw new Error("No paths specified for archiving.");
}
const tempDir = await fs3.promises.mkdtemp(path2.join(os2.tmpdir(), "cache-"));
const archivePath = path2.join(tempDir, `${sanitizeKey(key)}.tar.zst`);
const quotedPaths = paths.map((p) => `"${expandPath(p)}"`).join(" ");
const cmd = `tar -cf - ${quotedPaths} | zstd -${cmprss_lvl} -o "${archivePath}"`;
console.log(`
\u{1F504} Compressing with zstd (Level: ${cmprss_lvl})...`);
const isCompressed = cmprss_lvl > 0;
const cmd = isCompressed ? `tar -cf - ${quotedPaths} | zstd -${cmprss_lvl} -o "${archivePath}"` : `tar -cf "${archivePath}" ${quotedPaths}`;
console.log(
isCompressed ? `
\u{1F504} Compressing with zstd (Level: ${cmprss_lvl})...` : `
\u{1F4E6} Creating uncompressed tar archive...`
);
const startTime = Date.now();
await execAsync(cmd, {
cwd: "/",
@@ -26349,7 +26353,14 @@ async function extractCompressedTar(archivePath, extractTo = "/") {
if (!fs3.existsSync(archivePath)) {
throw new Error(`Archive not found: ${archivePath}`);
}
const cmd = `zstd -dc "${archivePath}" | tar -xf - -C "${extractTo}"`;
const type = await detectArchiveType(archivePath);
if (type === "unknown") {
console.error(
`\u26A0\uFE0F Unknown archive type for ${archivePath}. Cannot extract.`
);
return;
}
const cmd = type === "zstd" ? `zstd -dc "${archivePath}" | tar -xf - -C "${extractTo}"` : `tar -xf "${archivePath}" -C "${extractTo}"`;
console.log(`
\u{1F4C2} Extracting archive: ${archivePath}`);
const startTime = Date.now();
@@ -26365,6 +26376,20 @@ async function extractCompressedTar(archivePath, extractTo = "/") {
console.log(`\u{1F4E6} Archive size: ${formatSize(size)}`);
console.log(`\u26A1 Speed: ${formatSpeed(size, duration)}`);
}
async function detectArchiveType(path3) {
const { stdout } = await execAsync(`file --brief --mime-type "${path3}"`);
const type = stdout.trim();
if (type === "application/zstd") {
return "zstd";
}
if (type === "application/x-tar" || type === "application/x-ustar") {
return "tar";
}
const { stdout: fileOutput } = await execAsync(`file "${path3}"`);
if (/Zstandard compressed data/.test(fileOutput)) return "zstd";
if (/tar archive/.test(fileOutput)) return "tar";
return "unknown";
}
// src/save.ts
async function saveCache(key, paths, cmprss_lvl = 3) {
@@ -26452,7 +26477,7 @@ async function run() {
(p) => p.trim() !== ""
);
let compression_level = parseInt(
core4.getInput("compression-level", { required: false }) || "3",
core4.getInput("compression-level", { required: false }) || "0",
10
);
if (isNaN(compression_level) || compression_level < 0 || compression_level > 6) {