From f58da941092534481b1972f45086faadd3335124 Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Tue, 21 Dec 2021 13:04:44 +0000 Subject: [PATCH] Allow users to specify a read-only cache This can reduce workflow runtime for situations, such as PRs, where the build artifacts may be disposable and of little use to other workflow runs. --- src/cleanup-java.ts | 3 ++- src/constants.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cleanup-java.ts b/src/cleanup-java.ts index a890c4b6..e52de8ef 100644 --- a/src/cleanup-java.ts +++ b/src/cleanup-java.ts @@ -23,7 +23,8 @@ async function removePrivateKeyFromKeychain() { async function saveCache() { const jobStatus = isJobStatusSuccess(); const cache = core.getInput(constants.INPUT_CACHE); - return jobStatus && cache ? save(cache) : Promise.resolve(); + const readOnlyCache = core.getInput(constants.INPUT_CACHE_READ_ONLY) + return jobStatus && cache && !readOnlyCache ? save(cache) : Promise.resolve(); } /** diff --git a/src/constants.ts b/src/constants.ts index 94d7667f..a5fdfeea 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -17,6 +17,7 @@ export const INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined; export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; export const INPUT_CACHE = 'cache'; +export const INPUT_CACHE_READ_ONLY = "cache-is-read-only"; export const INPUT_JOB_STATUS = 'job-status'; export const STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';