From b02f4f1968f1dab6ba1080fb52df0795021f896b Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Sat, 4 Jun 2022 11:28:12 -0600 Subject: [PATCH] Disable cache-read-only when cache-write-only is set --- action.yml | 11 +++++++---- src/cache-utils.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 1e42ea7..02e3c09 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,13 @@ inputs: # e.g. Use the following setting to only write cache entries from your 'main' branch # cache-read-only: ${{ github.ref_name != 'main' }} + cache-write-only: + description: | + When 'true', entries will not be restored from the cache but will be saved at the end of the Job. + Setting this to 'true' implies cache-read-only will be 'false'. + required: false + default: false + gradle-home-cache-includes: description: Paths within Gradle User Home to cache. required: false @@ -52,10 +59,6 @@ inputs: # The following action properties allow fine-grained tweaking of the action caching behaviour. # These properties are experimental and not (yet) designed for production use, and may change without notice in a subsequent release of `gradle-build-action`. # Use at your own risk! - cache-write-only: - description: When 'true', entries will not be restored from the cache but will be saved at the end of the Job. This allows a 'clean' cache entry to be written. - required: false - default: false gradle-home-cache-strict-match: description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs. required: false diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 5b605ef..d5087a3 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -27,7 +27,7 @@ export function isCacheDisabled(): boolean { } export function isCacheReadOnly(): boolean { - return core.getBooleanInput(CACHE_READONLY_PARAMETER) + return !isCacheWriteOnly() && core.getBooleanInput(CACHE_READONLY_PARAMETER) } export function isCacheWriteOnly(): boolean {