mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-07-12 10:15:51 +02:00
Restore/save configuration-cache data in first action
Previously, the action was restoring/saving the configuration-cache data for each step that applied the action. In order to support Gradle invocations that are _not_ managed by the action, the configuration-cache restore is now performed in the initial action step, and save is performed in the final post-action step. The build root directories are recorded for each invocation via an init script.
This commit is contained in:
parent
1041604f29
commit
e1f84aa44d
6 changed files with 107 additions and 75 deletions
13
src/main.ts
13
src/main.ts
|
@ -1,5 +1,6 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as path from 'path'
|
||||
import * as os from 'os'
|
||||
import {parseArgsStringToArgv} from 'string-argv'
|
||||
|
||||
import * as caches from './caches'
|
||||
|
@ -14,8 +15,9 @@ export async function run(): Promise<void> {
|
|||
try {
|
||||
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
||||
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
|
||||
const gradleUserHome = determineGradleUserHome(buildRootDirectory)
|
||||
|
||||
await caches.restore(buildRootDirectory)
|
||||
await caches.restore(gradleUserHome)
|
||||
|
||||
const args: string[] = parseCommandLineArguments()
|
||||
|
||||
|
@ -63,6 +65,15 @@ function resolveBuildRootDirectory(baseDirectory: string): string {
|
|||
return resolvedBuildRootDirectory
|
||||
}
|
||||
|
||||
function determineGradleUserHome(rootDir: string): string {
|
||||
const customGradleUserHome = process.env['GRADLE_USER_HOME']
|
||||
if (customGradleUserHome) {
|
||||
return path.resolve(rootDir, customGradleUserHome)
|
||||
}
|
||||
|
||||
return path.resolve(os.homedir(), '.gradle')
|
||||
}
|
||||
|
||||
function parseCommandLineArguments(): string[] {
|
||||
const input = core.getInput('arguments')
|
||||
return parseArgsStringToArgv(input)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue