mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-01-14 18:01:38 -05:00
a72af0b6a6
Instead of writing this file to a temp directory and referencing it on the Gradle command line, the init script is now written to Gradle User Home so that it is picked up automatically.
32 lines
892 B
TypeScript
32 lines
892 B
TypeScript
import * as exec from '@actions/exec'
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
export async function execute(executable: string, root: string, args: string[]): Promise<BuildResult> {
|
|
let buildScanUrl: string | undefined
|
|
|
|
const buildScanFile = path.resolve(root, 'gradle-build-scan.txt')
|
|
if (fs.existsSync(buildScanFile)) {
|
|
fs.unlinkSync(buildScanFile)
|
|
}
|
|
|
|
const status: number = await exec.exec(executable, args, {
|
|
cwd: root,
|
|
ignoreReturnCode: true
|
|
})
|
|
|
|
if (fs.existsSync(buildScanFile)) {
|
|
buildScanUrl = fs.readFileSync(buildScanFile, 'utf-8')
|
|
}
|
|
|
|
return new BuildResultImpl(status, buildScanUrl)
|
|
}
|
|
|
|
export interface BuildResult {
|
|
readonly status: number
|
|
readonly buildScanUrl?: string
|
|
}
|
|
|
|
class BuildResultImpl implements BuildResult {
|
|
constructor(readonly status: number, readonly buildScanUrl?: string) {}
|
|
}
|