Skip to content

Commit

Permalink
Display multi-gitter output
Browse files Browse the repository at this point in the history
  • Loading branch information
willsawyerrrr committed Jan 22, 2024
1 parent 26ea56c commit 56ea60f
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,25 @@ async function run({ payload }: EmitterWebhookEvent<"pull_request">) {
repo: payload.repository.name,
});

let output: Buffer;
try {
output = execSync("multi-gitter run /tmp/script.sh --config /tmp/config.yaml");
} catch (error) {
const output = (error as SpawnSyncReturns<Buffer>).stdout.toString();

await safeOctokitRequest(octokit.rest.issues.updateComment, {
body: ["Failed to run `multi-gitter`:", "```", output, "```"].join("\n"),
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
comment_id: commentId,
});

return;
}

await safeOctokitRequest(octokit.rest.issues.updateComment, {
body: "Done running `multi-gitter`.",
body: ["Done running `multi-gitter`:", "```", output, "```"].join("\n"),
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
Expand Down Expand Up @@ -120,15 +137,14 @@ async function verify({ payload }: EmitterWebhookEvent<"pull_request">) {
});
});

let result: Buffer;
let output: Buffer;
try {
result = execSync("multi-gitter run /tmp/script.sh --config /tmp/config.yaml --dry-run");
output = execSync("multi-gitter run /tmp/script.sh --config /tmp/config.yaml");
} catch (error) {
const stdout = (error as SpawnSyncReturns<Buffer>).stdout.toString();
const stderr = (error as SpawnSyncReturns<Buffer>).stderr.toString();
const output = (error as SpawnSyncReturns<Buffer>).stdout.toString();

await safeOctokitRequest(octokit.rest.issues.updateComment, {
body: "Failed to run `multi-gitter`.",
body: ["Failed to run `multi-gitter`:", "```", output, "```"].join("\n"),
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
Expand All @@ -139,7 +155,7 @@ async function verify({ payload }: EmitterWebhookEvent<"pull_request">) {
}

await safeOctokitRequest(octokit.rest.issues.updateComment, {
body: "Done verifying.",
body: ["Done running `multi-gitter`:", "```", output, "```"].join("\n"),
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
Expand Down

0 comments on commit 56ea60f

Please sign in to comment.