feat: auto-assign issues and prs to naomi
Node.js CI / Lint and Test (push) Successful in 42s

This commit is contained in:
2025-08-27 17:58:28 -07:00
parent c48242a141
commit 1b7f83f335
8 changed files with 874 additions and 9 deletions
+29 -3
View File
@@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import type { Amari } from "../interfaces/amari.js";
import type { IssueCreated,
PullRequestCreated,
GithubPayload } from "../interfaces/github.js";
@@ -19,10 +20,12 @@ const isPull = (body: GithubPayload): body is PullRequestCreated => {
/**
* Handles a payload from a GitHub webhook.
* @param amari - Amari's instance.
* @param request - The Fastify request payload.
* @param response - The Fastify reply class.
*/
export const processGithubEvent = async(
amari: Amari,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Fastify standard.
request: FastifyRequest<{ Body: GithubPayload }>,
response: FastifyReply,
@@ -37,7 +40,30 @@ export const processGithubEvent = async(
await response.status(200).send({ message: "Pong!" });
return;
}
const { action: _action } = request.body;
isIssue(request.body);
isPull(request.body);
const { action } = request.body;
await response.status(200).send({ message: "Payload received!" });
if (action === "opened" && event === "issue" && isIssue(request.body)) {
const { issue, repository } = request.body;
const { number } = issue;
const { owner, name } = repository;
await amari.github.rest.issues.addAssignees({
assignees: [ "naomi-lgbt" ],
// eslint-disable-next-line @typescript-eslint/naming-convention -- Github SDK requirement.
issue_number: number,
owner: owner.login,
repo: name,
});
}
if (action === "opened" && event === "pull_request" && isPull(request.body)) {
const { pull_request: pr, repository } = request.body;
const { number } = pr;
const { owner, name } = repository;
await amari.github.rest.pulls.requestReviewers({
owner: owner.login,
// eslint-disable-next-line @typescript-eslint/naming-convention -- Github SDK requirement.
pull_number: number,
repo: name,
reviewers: [ "naomi-lgbt" ],
});
}
};