From 293503e0993f3d9808a5d03549ddf3cbf6c88b51 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 17 Apr 2023 14:07:53 -0700 Subject: [PATCH] Add autoclean. --- index.ts | 4 ++++ post.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/index.ts b/index.ts index 7bb6789..bd29f81 100644 --- a/index.ts +++ b/index.ts @@ -171,6 +171,10 @@ async function installBins() { .filter(Boolean) .map((bin) => (bin.startsWith('cargo-') ? bin : `cargo-${bin}`)); + if (core.getBooleanInput('cache')) { + bins.push('cargo-cache'); + } + if (bins.length === 0) { return; } diff --git a/post.ts b/post.ts index 651cfde..dba0814 100644 --- a/post.ts +++ b/post.ts @@ -1,5 +1,6 @@ import * as cache from '@actions/cache'; import * as core from '@actions/core'; +import * as exec from '@actions/exec'; import { getPathsToCache, getPrimaryCacheKey } from './helpers'; async function saveCache() { @@ -17,6 +18,10 @@ async function saveCache() { return; } + core.info('Cleaning cache before saving'); + + await exec.exec('cargo', ['cache', '--autoclean']); + core.info(`Saving cache with key ${primaryKey}`); await cache.saveCache(getPathsToCache(), primaryKey, {}, false);