Skip to content

Commit

Permalink
Follow-up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
willsawyerrrr committed Jan 18, 2024
1 parent 2010431 commit ec3985e
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,60 @@ export async function handler(event: APIGatewayEvent): Promise<APIGatewayProxyRe
async function run({ payload }: EmitterWebhookEvent<"pull_request">) {
const octokit = await app.getInstallationOctokit(payload.installation!.id);

const message = payload.pull_request.merged
? "Running `multi-gitter`..."
: "Pull request was closed without merging.";
if (!payload.pull_request.merged) {
await octokit.rest.issues.createComment({
body: "Pull request was closed without merging.",
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
});

await octokit.rest.issues.createComment({
body: message,
return;
}

const { data, status } = await octokit.rest.issues.createComment({
body: "Running `multi-gitter`...",
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
});

if (!(status >= 200 && status < 300)) {
return;
}

await octokit.rest.issues.updateComment({
body: "Done running `multi-gitter`.",
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
comment_id: data.id,
});

// check verification status
// ideally, validate and use the previous verification status
// otherwise, re-verify the pull request contents
}

async function verify({ payload }: EmitterWebhookEvent<"pull_request">) {
const octokit = await app.getInstallationOctokit(payload.installation!.id);

await octokit.rest.issues.createComment({
const { data, status } = await octokit.rest.issues.createComment({
body: "Verifying pull request contents...",
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
});

if (!(status >= 200 && status < 300)) {
return;
}

await octokit.rest.issues.updateComment({
body: "Done verifying.",
issue_number: payload.pull_request.number,
owner: payload.repository.owner.login,
repo: payload.repository.name,
comment_id: data.id,
});
}

0 comments on commit ec3985e

Please sign in to comment.