Skip to content

feat(content-extractor): add support for pull_request triggers#89

Open
avivkeller wants to merge 1 commit intogithub:mainfrom
avivkeller:patch-1
Open

feat(content-extractor): add support for pull_request triggers#89
avivkeller wants to merge 1 commit intogithub:mainfrom
avivkeller:patch-1

Conversation

@avivkeller
Copy link
Copy Markdown

As titled. Adds support for pull request related triggers. While this can't see PR content, it can still moderate for AI-like PR bodies

@avivkeller avivkeller requested a review from a team as a code owner March 31, 2026 15:51
Copilot AI review requested due to automatic review settings March 31, 2026 15:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for pull_request and pull_request_target webhook events so the action can extract and evaluate PR title/body content when a PR is opened.

Changes:

  • Extend extractFromEvent to extract content/number from pull_request and pull_request_target opened events.
  • Update shouldProcess to allow processing of PR opened events for those triggers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 20 to +26
content = `${context.payload.issue?.title}\n${context.payload.issue?.body}`
issueNumber = context.payload.issue?.number ?? null
} else if (
(event === 'pull_request' || event === 'pull_request_target') &&
context.payload.action === 'opened'
) {
content = `${context.payload.pull_request?.title}\n${context.payload.pull_request?.body}`
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this new pull_request/pull_request_target branch, interpolating optional title/body into a template literal will stringify null/undefined (e.g., "...\nnull"), which can pollute moderation input and potentially cause false positives. Consider normalizing with ?? '' (and optionally trimming) so missing fields don't become the literal strings "null"/"undefined".

Suggested change
content = `${context.payload.issue?.title}\n${context.payload.issue?.body}`
issueNumber = context.payload.issue?.number ?? null
} else if (
(event === 'pull_request' || event === 'pull_request_target') &&
context.payload.action === 'opened'
) {
content = `${context.payload.pull_request?.title}\n${context.payload.pull_request?.body}`
const title = context.payload.issue?.title ?? ''
const body = context.payload.issue?.body ?? ''
content = `${title}\n${body}`.trim()
issueNumber = context.payload.issue?.number ?? null
} else if (
(event === 'pull_request' || event === 'pull_request_target') &&
context.payload.action === 'opened'
) {
const title = context.payload.pull_request?.title ?? ''
const body = context.payload.pull_request?.body ?? ''
content = `${title}\n${body}`.trim()

Copilot uses AI. Check for mistakes.
Comment on lines 56 to +60

return (
(event === 'issues' && context.payload.action === 'opened') ||
((event === 'pull_request' || event === 'pull_request_target') &&
context.payload.action === 'opened') ||
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New support for pull_request / pull_request_target events is added here, but there are existing Jest tests for extractFromEvent/shouldProcess and none cover these new event types. Please add tests for both events with action opened (including title/body extraction) to prevent regressions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants