Skip to content

Commit 55c0634

Browse files
fix(github-webhook): check membership across multiple teams (#7706)
1 parent c88461f commit 55c0634

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

  • apps/docs/src/app/api/github-webhook

apps/docs/src/app/api/github-webhook/route.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ export async function POST(req: Request) {
3333

3434
const isMember = pr.author_association === "MEMBER";
3535

36-
const teamRes = await fetch(
37-
`https://api.github.com/orgs/prisma/teams/dev-connections-write/memberships/${pr.user.login}`,
38-
{
39-
headers: {
40-
Authorization: `Bearer ${process.env.BOT_TOKEN_GITHUB_PR_LINEAR_WEBHOOK!}`,
41-
"X-GitHub-Api-Version": "2022-11-28",
42-
},
43-
}
36+
const teamSlugs = ["dev-connections-write", "webdev-write"] as const;
37+
const authHeaders = {
38+
Authorization: `Bearer ${process.env.BOT_TOKEN_GITHUB_PR_LINEAR_WEBHOOK!}`,
39+
"X-GitHub-Api-Version": "2022-11-28",
40+
} as const;
41+
const membershipResults = await Promise.all(
42+
teamSlugs.map((slug) =>
43+
fetch(
44+
`https://api.github.com/orgs/prisma/teams/${encodeURIComponent(slug)}/memberships/${encodeURIComponent(pr.user.login)}`,
45+
{ headers: authHeaders }
46+
)
47+
)
4448
);
45-
const isTeamMember = teamRes.status === 200;
49+
const isTeamMember = membershipResults.some((r) => r.status === 200);
4650

4751
if (isMember || isTeamMember) {
4852
return new Response("Internal contributor, skipping", { status: 200 });

0 commit comments

Comments
 (0)