Skip to content

Commit

Permalink
fix: only consider award comments on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamPalriwala committed Feb 13, 2024
1 parent f231699 commit f2432bc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/github/hooks/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,23 @@ export const onAwardPoints = async (webhooks: Webhooks) => {
webhooks.on(EVENT_TRIGGERS.ISSUE_COMMENTED, async (context) => {
try {
const octokit = getOctokitInstance(context.payload.installation?.id!);

const issueNumber = context.payload.issue.number;
const repo = context.payload.repository.name;
const issueCommentBody = context.payload.comment.body;

const awardPointsRegex = new RegExp(`${AWARD_POINTS_IDENTIFIER}\\s+(\\d+)`);
const match = issueCommentBody.match(awardPointsRegex);
const isPR = !!context.payload.issue.pull_request;
const issueNumber = isPR ? context.payload.issue.number : undefined;

let comment: string = "";

if (match) {
const points = parseInt(match[1], 10);

if (!issueNumber) {
console.error("Comment is not on a PR.");
return;
}

const ossGgRepo = await getRepositoryByGithubId(context.payload.repository.id);

let usersThatCanAwardPoints = ossGgRepo?.installation.memberships.map((m) => m.userId);
Expand Down

0 comments on commit f2432bc

Please sign in to comment.