diff --git a/dist/save-cache/index.js b/dist/save-cache/index.js index 5742afc..a5483b3 100644 --- a/dist/save-cache/index.js +++ b/dist/save-cache/index.js @@ -82889,6 +82889,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.run = void 0; const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); +const exec = __importStar(__nccwpck_require__(1514)); const restore_cache_1 = __nccwpck_require__(1898); const inputs_1 = __nccwpck_require__(9378); function run() { @@ -82915,15 +82916,25 @@ function saveCache() { return; } else if (matchedKey === cacheKey) { - // no change in target directories core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`); return; } + yield pruneCache(); core.info(`Saving cache path: ${inputs_1.cacheLocalPath}`); yield cache.saveCache([inputs_1.cacheLocalPath], cacheKey); core.info(`cache saved with the key: ${cacheKey}`); }); } +function pruneCache() { + return __awaiter(this, void 0, void 0, function* () { + const options = { + silent: !core.isDebug() + }; + const execArgs = ['cache', 'prune', '--ci']; + core.info('Pruning cache...'); + yield exec.exec('uv', execArgs, options); + }); +} run(); diff --git a/src/save-cache.ts b/src/save-cache.ts index ba29d74..0a5e980 100644 --- a/src/save-cache.ts +++ b/src/save-cache.ts @@ -1,5 +1,6 @@ import * as cache from '@actions/cache' import * as core from '@actions/core' +import * as exec from '@actions/exec' import {STATE_CACHE_MATCHED_KEY, STATE_CACHE_KEY} from './cache/restore-cache' import {cacheLocalPath, enableCache} from './utils/inputs' @@ -23,14 +24,26 @@ async function saveCache(): Promise { core.warning('Error retrieving cache key from state.') return } else if (matchedKey === cacheKey) { - // no change in target directories core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`) return } + + await pruneCache() + core.info(`Saving cache path: ${cacheLocalPath}`) await cache.saveCache([cacheLocalPath], cacheKey) core.info(`cache saved with the key: ${cacheKey}`) } +async function pruneCache(): Promise { + const options: exec.ExecOptions = { + silent: !core.isDebug() + } + const execArgs = ['cache', 'prune', '--ci'] + + core.info('Pruning cache...') + await exec.exec('uv', execArgs, options) +} + run()