mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-09-12 02:32:22 +08:00
Add input to make the dependencies caching strict
This commit is contained in:
@@ -18,6 +18,8 @@ export async function restoreCachedDependencies(
|
||||
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||
|
||||
const inputCacheExact = github.inputBoolean('dependencies-cache-exact')
|
||||
|
||||
const inputCacheKeyGlobs = github.inputArrayOrNull('dependencies-cache-key')
|
||||
const cacheKeyGlobs = inputCacheKeyGlobs
|
||||
? inputCacheKeyGlobs
|
||||
@@ -33,9 +35,11 @@ export async function restoreCachedDependencies(
|
||||
const cacheKey = `${cacheKeyPrefix}${hash}`
|
||||
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
||||
|
||||
const cacheResult = await cache.restoreCache([cachePath], cacheKey, [
|
||||
cacheKeyPrefix
|
||||
])
|
||||
const cacheResult = await cache.restoreCache(
|
||||
[cachePath],
|
||||
cacheKey,
|
||||
inputCacheExact ? [] : [cacheKeyPrefix]
|
||||
)
|
||||
core.saveState(DEPENDENCIES_CACHE_RESULT, cacheResult)
|
||||
}
|
||||
|
||||
|
@@ -16,3 +16,9 @@ export function inputArrayOrNull(name: string): string[] | null {
|
||||
.map(s => s.trim())
|
||||
.filter(s => s !== '')
|
||||
}
|
||||
|
||||
export function inputBoolean(name: string, defaultValue = false): boolean {
|
||||
const string = inputOrNull(name)
|
||||
if (!string) return defaultValue
|
||||
return string === 'true'
|
||||
}
|
||||
|
Reference in New Issue
Block a user