mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-03 13:41:03 -05:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
|
import * as exec from "@actions/exec";
|
||
|
|
||
|
|
||
|
export async function execute(executable: string, root: string, argv: string[]): Promise<BuildResult> {
|
||
|
|
||
|
let publishing = false;
|
||
|
let buildScanLink: any = null;
|
||
|
|
||
|
await exec.exec(executable, argv, {
|
||
|
cwd: root,
|
||
|
listeners: {
|
||
|
stdline: (line: string) => {
|
||
|
if (line.startsWith("Publishing build scan...")) {
|
||
|
publishing = true;
|
||
|
}
|
||
|
if (publishing && line.length == 0) {
|
||
|
publishing = false
|
||
|
}
|
||
|
if (publishing && line.startsWith("http")) {
|
||
|
buildScanLink = line.trim();
|
||
|
publishing = false
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
if (buildScanLink != null) {
|
||
|
return new BuildResultImpl(buildScanLink.toString());
|
||
|
}
|
||
|
return new BuildResultImpl(null as unknown as string);
|
||
|
}
|
||
|
|
||
|
export interface BuildResult {
|
||
|
buildScanUrl: string
|
||
|
}
|
||
|
|
||
|
class BuildResultImpl implements BuildResult {
|
||
|
constructor(readonly buildScanUrl: string) {
|
||
|
}
|
||
|
}
|