Add autoclean.

This commit is contained in:
Miles Johnson 2023-04-17 14:07:53 -07:00
parent 8cbd5dda6b
commit 293503e099
2 changed files with 9 additions and 0 deletions

View file

@ -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;
}

View file

@ -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);