mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Add input to disable dependencies caching altogether
This commit is contained in:
parent
7c8cc1a9ef
commit
3abad5567a
4 changed files with 13 additions and 2 deletions
|
@ -20,6 +20,9 @@ inputs:
|
|||
arguments:
|
||||
description: Gradle command line arguments, see gradle --help
|
||||
required: false
|
||||
dependencies-cache-enabled:
|
||||
description: Whether caching dependencies is enabled or not, default to 'true'
|
||||
required: false
|
||||
dependencies-cache-key:
|
||||
description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset
|
||||
required: false
|
||||
|
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,8 @@ const DEPENDENCIES_CACHE_RESULT = 'DEPENDENCIES_CACHE_RESULT'
|
|||
export async function restoreCachedDependencies(
|
||||
rootDir: string
|
||||
): Promise<void> {
|
||||
if (isDependenciesCacheDisabled()) return
|
||||
|
||||
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||
|
||||
|
@ -52,6 +54,8 @@ export async function restoreCachedDependencies(
|
|||
}
|
||||
|
||||
export async function cacheDependencies(): Promise<void> {
|
||||
if (isDependenciesCacheDisabled()) return
|
||||
|
||||
const cachePath = core.getState(DEPENDENCIES_CACHE_PATH)
|
||||
const cacheKey = core.getState(DEPENDENCIES_CACHE_KEY)
|
||||
const cacheResult = core.getState(DEPENDENCIES_CACHE_RESULT)
|
||||
|
@ -107,3 +111,7 @@ function tryDeleteFiles(filePaths: string[]): boolean {
|
|||
}
|
||||
return !failure
|
||||
}
|
||||
|
||||
function isDependenciesCacheDisabled(): boolean {
|
||||
return !github.inputBoolean('dependencies-cache-enabled', true)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue