feat: add option to disable cache pruning (#134)

This PR adds an input to control whether or not the cache is pruned
before saving.

Closes #122

---------

Co-authored-by: Kevin Stillhammer <kevin.stillhammer@gmail.com>
Co-authored-by: Charlie Marsh <crmarsh416@gmail.com>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
Merlin 2024-10-25 08:11:32 -04:00 committed by GitHub
parent cf841c25e2
commit 3b9817b1bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 39 additions and 5 deletions

View file

@ -5,7 +5,11 @@ import {
STATE_CACHE_MATCHED_KEY,
STATE_CACHE_KEY,
} from "./cache/restore-cache";
import { cacheLocalPath, enableCache } from "./utils/inputs";
import {
cacheLocalPath,
enableCache,
pruneCache as shouldPruneCache,
} from "./utils/inputs";
export async function run(): Promise<void> {
try {
@ -32,7 +36,9 @@ async function saveCache(): Promise<void> {
return;
}
await pruneCache();
if (shouldPruneCache) {
await pruneCache();
}
core.info(`Saving cache path: ${cacheLocalPath}`);
await cache.saveCache([cacheLocalPath], cacheKey);

View file

@ -7,6 +7,7 @@ export const enableCache = core.getInput("enable-cache") === "true";
export const cacheSuffix = core.getInput("cache-suffix") || "";
export const cacheLocalPath = getCacheLocalPath();
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
export const pruneCache = core.getInput("prune-cache") === "true";
export const toolBinDir = getToolBinDir();
export const toolDir = getToolDir();
export const githubToken = core.getInput("github-token");