diff --git a/action.yml b/action.yml index 69ab1cd..8d032bc 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,10 @@ inputs: required: false default: "true" description: 'if false, will not run `rtx install`' + cache: + required: false + default: "true" + description: 'if false, action will not automatically cache' outputs: cache-hit: description: 'A boolean value to indicate if a cache was hit.' diff --git a/dist/index.js b/dist/index.js index 50d1a45..b90f4d0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -82932,7 +82932,14 @@ const path = __importStar(__nccwpck_require__(1017)); const utils_1 = __nccwpck_require__(1314); async function run() { await setToolVersions(); - await restoreRTXCache(); + if (core.getBooleanInput('cache')) { + await restoreRTXCache(); + core.saveState('CACHE', false); + } + else { + core.saveState('CACHE', true); + core.setOutput('cache-hit', false); + } await setupRTX(); await setEnvVars(); await exec.exec('rtx', ['--version']); diff --git a/src/cache-save.ts b/src/cache-save.ts index ece5149..8d5ad45 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -12,6 +12,13 @@ export async function run(): Promise { } async function cacheRTXTools(): Promise { + const skipCache = core.getState('CACHE') + + if (skipCache) { + core.info('Skipping saving cache') + return + } + const state = core.getState('CACHE_KEY') const primaryKey = core.getState('PRIMARY_KEY') const cachePath = rtxDir() diff --git a/src/main.ts b/src/main.ts index 0428372..d5a6609 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,15 @@ import { rtxDir } from './utils' async function run(): Promise { await setToolVersions() - await restoreRTXCache() + + if (core.getBooleanInput('cache')) { + await restoreRTXCache() + core.saveState('CACHE', false) + } else { + core.saveState('CACHE', true) + core.setOutput('cache-hit', false) + } + await setupRTX() await setEnvVars() await exec.exec('rtx', ['--version'])