gradle-build-action/src/main.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-06-13 07:44:30 -04:00
import * as core from '@actions/core'
2019-09-21 10:01:53 -04:00
import * as setupGradle from './setup-gradle'
2020-06-13 07:44:30 -04:00
import * as execution from './execution'
import * as provisioner from './provision'
import * as layout from './repository-layout'
import * as params from './input-params'
2019-09-21 10:01:53 -04:00
/**
* The main entry point for the action, called by Github Actions for the step.
*/
2020-06-13 07:54:27 -04:00
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()
2019-09-21 10:01:53 -04:00
// Only execute if arguments have been provided
const args: string[] = params.getArguments()
if (args.length > 0) {
const buildRootDirectory = layout.buildRootDirectory()
await execution.executeGradleBuild(executable, buildRootDirectory, args)
2019-09-23 06:11:18 -04:00
}
2019-09-21 10:01:53 -04:00
} catch (error) {
core.setFailed(String(error))
if (error instanceof Error && error.stack) {
core.info(error.stack)
}
2019-09-21 10:01:53 -04:00
}
2019-09-20 17:06:59 -04:00
}
2020-06-13 07:44:30 -04:00
run()