mirror of
https://github.com/gradle/actions.git
synced 2025-04-20 09:49:19 +08:00
Introducing new actions for the GitHub dependency graph will involve reuse of much of the action infrastructure. This commit reorganises things a little to facilitate reuse.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import * as core from '@actions/core'
|
|
import {parseArgsStringToArgv} from 'string-argv'
|
|
|
|
import * as setupGradle from './setup-gradle'
|
|
import * as execution from './execution'
|
|
import * as provisioner from './provision'
|
|
import * as layout from './repository-layout'
|
|
|
|
/**
|
|
* The main entry point for the action, called by Github Actions for the step.
|
|
*/
|
|
export async function run(): Promise<void> {
|
|
try {
|
|
// Configure Gradle environment (Gradle User Home)
|
|
await setupGradle.setup()
|
|
|
|
// Download and install Gradle if required
|
|
const executable = await provisioner.provisionGradle()
|
|
|
|
// Only execute if arguments have been provided
|
|
const args: string[] = parseCommandLineArguments()
|
|
if (args.length > 0) {
|
|
const buildRootDirectory = layout.buildRootDirectory()
|
|
await execution.executeGradleBuild(executable, buildRootDirectory, args)
|
|
}
|
|
} catch (error) {
|
|
core.setFailed(String(error))
|
|
if (error instanceof Error && error.stack) {
|
|
core.info(error.stack)
|
|
}
|
|
}
|
|
}
|
|
|
|
run()
|
|
|
|
function parseCommandLineArguments(): string[] {
|
|
const input = core.getInput('arguments')
|
|
return parseArgsStringToArgv(input)
|
|
}
|