Skip to content

Commit c7a324f

Browse files
committed
fix
1 parent 44a53b2 commit c7a324f

4 files changed

Lines changed: 17 additions & 25 deletions

File tree

action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ inputs:
3333
description: "Maximum number of concurrent BuildKit RUN steps. Defaults to the number of vCPUs on the runner."
3434
required: false
3535
cache-keep-storage:
36-
description: "Amount of build cache to retain after pruning, in MB (e.g., 1000 for 1GB). Defaults to 20480 (20GB)."
36+
description: "Amount of build cache to retain after pruning, in MB (e.g., 20480 for 20GB). If not set, pruning is skipped."
3737
required: false
38-
default: "20480"
3938
runs:
4039
using: node24
4140
main: dist/index.js

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ export interface Inputs {
314314
"skip-integrity-check": boolean;
315315
"driver-opts": string[];
316316
"max-parallelism": number | null;
317-
"cache-keep-storage": number;
318317
}
319318

320319
async function getInputs(): Promise<Inputs> {
@@ -331,19 +330,6 @@ async function getInputs(): Promise<Inputs> {
331330
}
332331
}
333332

334-
const cacheKeepStorageInput = core.getInput("cache-keep-storage");
335-
let cacheKeepStorage = 20480;
336-
if (cacheKeepStorageInput) {
337-
const parsed = parseInt(cacheKeepStorageInput, 10);
338-
if (!isNaN(parsed) && parsed >= 0) {
339-
cacheKeepStorage = parsed;
340-
} else {
341-
core.warning(
342-
`Invalid cache-keep-storage value '${cacheKeepStorageInput}', ignoring. Must be a non-negative integer (MB). Using default 20480 MB.`,
343-
);
344-
}
345-
}
346-
347333
return {
348334
"buildx-version": core.getInput("buildx-version"),
349335
"buildkit-version": core.getInput("buildkit-version"),
@@ -356,7 +342,6 @@ async function getInputs(): Promise<Inputs> {
356342
quote: false,
357343
}),
358344
"max-parallelism": maxParallelism,
359-
"cache-keep-storage": cacheKeepStorage,
360345
};
361346
}
362347

@@ -579,12 +564,20 @@ async function maybeShutdownBuildkitd(): Promise<void> {
579564

580565
try {
581566
const keepStorageInput = core.getInput("cache-keep-storage");
582-
const keepStorageMB = keepStorageInput
583-
? parseInt(keepStorageInput, 10)
584-
: 20480;
585-
core.info(`Pruning BuildKit cache (keep at least ${keepStorageMB} MB)`);
586-
await pruneBuildkitCache(keepStorageMB);
587-
core.info("BuildKit cache pruned");
567+
if (!keepStorageInput) {
568+
core.info("Skipping BuildKit cache pruning (cache-keep-storage not set)");
569+
} else {
570+
const keepStorageMB = parseInt(keepStorageInput, 10);
571+
if (isNaN(keepStorageMB) || keepStorageMB < 0) {
572+
core.warning(
573+
`Invalid cache-keep-storage value '${keepStorageInput}', skipping pruning. Must be a non-negative integer (MB).`,
574+
);
575+
} else {
576+
core.info(`Pruning BuildKit cache (keep at least ${keepStorageMB} MB)`);
577+
await pruneBuildkitCache(keepStorageMB);
578+
core.info("BuildKit cache pruned");
579+
}
580+
}
588581
} catch (error) {
589582
core.warning(`Error pruning BuildKit cache: ${(error as Error).message}`);
590583
}

0 commit comments

Comments
 (0)