Skip to content

Commit

Permalink
feat: handle DO NOT MERGE label (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
naomi-lgbt authored Nov 12, 2024
1 parent ba24198 commit de60c30
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/server/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,34 @@ export const instantiateServer = async(
// It's valid, so send an ok response immediately
await response.status(200).send("OK~!");

if (event === "pull_request") {
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/consistent-type-assertions
const { action, pull_request, label } = request.body as {
action: string;
// eslint-disable-next-line @typescript-eslint/naming-convention
pull_request: { title: string; html_url: string; number: number };
label?: { name: string };
};
if (label?.name !== "DO NOT MERGE"
|| ![ "labeled", "unlabeled" ].includes(action)) {
return;
}
await camperChan.octokit.rest.pulls.createReview({
body: action === "labeled"
// eslint-disable-next-line stylistic/max-len
? "This PR has been marked as DO NOT MERGE. When you are ready to merge it, remove the label and I'll unblock the PR."
// eslint-disable-next-line stylistic/max-len
: "This PR has been unmarked as DO NOT MERGE. You may now merge this PR.",
event: action === "labeled"
? "REQUEST_CHANGES"
: "APPROVE",
owner: "nhcarrigan",
// eslint-disable-next-line @typescript-eslint/naming-convention
pull_number: pull_request.number,
repo: "camperchan",
});
}

if (event === "issues") {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const { action, issue, label } = request.body as {
Expand Down

0 comments on commit de60c30

Please sign in to comment.