mirror of
https://github.com/gradle/actions.git
synced 2025-11-26 17:09:10 +08: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:
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)
|
||||
|
||||
Reference in New Issue
Block a user