2020-06-13 11:44:30 +00:00
|
|
|
import * as core from '@actions/core'
|
|
|
|
import {parseArgsStringToArgv} from 'string-argv'
|
2019-09-21 14:01:53 +00:00
|
|
|
|
2022-06-02 18:17:56 +00:00
|
|
|
import * as setupGradle from './setup-gradle'
|
2020-06-13 11:44:30 +00:00
|
|
|
import * as execution from './execution'
|
2023-06-03 20:09:52 +00:00
|
|
|
import * as provisioner from './provision'
|
|
|
|
import * as layout from './repository-layout'
|
2019-09-21 14:01:53 +00:00
|
|
|
|
2021-11-28 17:19:56 +00:00
|
|
|
/**
|
|
|
|
* The main entry point for the action, called by Github Actions for the step.
|
|
|
|
*/
|
2020-06-13 11:54:27 +00:00
|
|
|
export async function run(): Promise<void> {
|
2021-09-14 11:33:50 +00:00
|
|
|
try {
|
2023-06-03 20:09:52 +00:00
|
|
|
// Configure Gradle environment (Gradle User Home)
|
|
|
|
await setupGradle.setup()
|
2021-08-23 02:14:47 +00:00
|
|
|
|
2023-06-03 20:09:52 +00:00
|
|
|
// Download and install Gradle if required
|
|
|
|
const executable = await provisioner.provisionGradle()
|
2019-09-21 14:01:53 +00:00
|
|
|
|
2021-12-08 16:05:04 +00:00
|
|
|
// Only execute if arguments have been provided
|
|
|
|
const args: string[] = parseCommandLineArguments()
|
|
|
|
if (args.length > 0) {
|
2023-06-03 20:09:52 +00:00
|
|
|
const buildRootDirectory = layout.buildRootDirectory()
|
2021-12-08 16:05:04 +00:00
|
|
|
await execution.executeGradleBuild(executable, buildRootDirectory, args)
|
2019-09-23 10:11:18 +00:00
|
|
|
}
|
2019-09-21 14:01:53 +00:00
|
|
|
} catch (error) {
|
2021-09-14 11:33:50 +00:00
|
|
|
core.setFailed(String(error))
|
|
|
|
if (error instanceof Error && error.stack) {
|
|
|
|
core.info(error.stack)
|
2021-09-06 17:16:08 +00:00
|
|
|
}
|
2019-09-21 14:01:53 +00:00
|
|
|
}
|
2019-09-20 21:06:59 +00:00
|
|
|
}
|
|
|
|
|
2020-06-13 11:44:30 +00:00
|
|
|
run()
|
2019-09-21 14:01:53 +00:00
|
|
|
|
|
|
|
function parseCommandLineArguments(): string[] {
|
2021-07-20 17:44:56 +00:00
|
|
|
const input = core.getInput('arguments')
|
|
|
|
return parseArgsStringToArgv(input)
|
2019-09-21 14:01:53 +00:00
|
|
|
}
|