mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-23 01:22:50 +00:00
Allow cache-paths to be set via action config
This commit is contained in:
parent
f901ec9c20
commit
9c95294209
2 changed files with 27 additions and 6 deletions
14
action.yml
14
action.yml
|
@ -26,12 +26,22 @@ inputs:
|
||||||
# TODO: It might be useful to default to read-only for PRs, or non-main branch.
|
# TODO: It might be useful to default to read-only for PRs, or non-main branch.
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
|
|
||||||
|
# EXPERIMENTAL & INTERNAL CONFIGURATION PROPERTIES
|
||||||
|
# The following action properties allow fine-grained tweaking of the action caching behaviour.
|
||||||
|
# These properties are not designed for production use, and may change without notice in a subsequent release of `gradle-build-action`.
|
||||||
|
# Use at your own risk!
|
||||||
workflow-job-context:
|
workflow-job-context:
|
||||||
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users.
|
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
|
||||||
required: false
|
required: false
|
||||||
default: ${{ toJSON(matrix) }}
|
default: ${{ toJSON(matrix) }}
|
||||||
|
cache-paths:
|
||||||
|
description: Paths in Gradle User Home to cache. (EXPERIMENTAL - may be changed/removed without notice)
|
||||||
|
required: false
|
||||||
|
default: |
|
||||||
|
["caches", "notifications"]
|
||||||
cache-artifact-bundles:
|
cache-artifact-bundles:
|
||||||
description: Names and patterns of artifact bundles to cache separately. For internal use only.
|
description: Names and patterns of artifact bundles to cache separately. (EXPERIMENTAL - may be changed/removed without notice)
|
||||||
required: false
|
required: false
|
||||||
default: |
|
default: |
|
||||||
[
|
[
|
||||||
|
|
|
@ -12,9 +12,6 @@ import {
|
||||||
tryDelete
|
tryDelete
|
||||||
} from './cache-utils'
|
} from './cache-utils'
|
||||||
|
|
||||||
// Which paths under Gradle User Home should be cached
|
|
||||||
const CACHE_PATH = ['caches', 'notifications']
|
|
||||||
|
|
||||||
export class GradleUserHomeCache extends AbstractCache {
|
export class GradleUserHomeCache extends AbstractCache {
|
||||||
private gradleUserHome: string
|
private gradleUserHome: string
|
||||||
|
|
||||||
|
@ -170,7 +167,21 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getCachePath(): string[] {
|
protected getCachePath(): string[] {
|
||||||
return CACHE_PATH.map(x => path.resolve(this.gradleUserHome, x))
|
const rawPaths: string[] = JSON.parse(core.getInput('cache-paths'))
|
||||||
|
rawPaths.push(META_FILE_DIR)
|
||||||
|
const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x))
|
||||||
|
this.debug(`Using cache paths: ${resolvedPaths}`)
|
||||||
|
return resolvedPaths
|
||||||
|
}
|
||||||
|
|
||||||
|
private resolveCachePath(rawPath: string): string {
|
||||||
|
if (rawPath.startsWith('!')) {
|
||||||
|
const resolved = this.resolveCachePath(rawPath.substring(1))
|
||||||
|
const negated = `!${resolved}`
|
||||||
|
this.debug(`Negate cache path: ${negated}`)
|
||||||
|
return negated
|
||||||
|
}
|
||||||
|
return path.resolve(this.gradleUserHome, rawPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getArtifactBundles(): Map<string, string> {
|
private getArtifactBundles(): Map<string, string> {
|
||||||
|
|
Loading…
Reference in a new issue