mirror of
https://github.com/gradle/actions.git
synced 2025-11-26 17:09:10 +08:00
Extract action state-tracking out of caches.ts
This commit is contained in:
15
src/main.ts
15
src/main.ts
@@ -1,9 +1,8 @@
|
||||
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'
|
||||
import * as setupGradle from './setup-gradle'
|
||||
import * as execution from './execution'
|
||||
import * as provision from './provision'
|
||||
|
||||
@@ -14,9 +13,8 @@ export async function run(): Promise<void> {
|
||||
try {
|
||||
const workspaceDirectory = process.env[`GITHUB_WORKSPACE`] || ''
|
||||
const buildRootDirectory = resolveBuildRootDirectory(workspaceDirectory)
|
||||
const gradleUserHome = determineGradleUserHome(buildRootDirectory)
|
||||
|
||||
await caches.restore(gradleUserHome)
|
||||
await setupGradle.setup(buildRootDirectory)
|
||||
|
||||
const executable = await provisionGradle(workspaceDirectory)
|
||||
// executable will be undefined if using Gradle wrapper
|
||||
@@ -60,15 +58,6 @@ 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