feat(content-extractor): add support for pull_request triggers#89
feat(content-extractor): add support for pull_request triggers#89avivkeller wants to merge 1 commit intogithub:mainfrom
pull_request triggers#89Conversation
There was a problem hiding this comment.
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
extractFromEventto extract content/number frompull_requestandpull_request_targetopenedevents. - Update
shouldProcessto allow processing of PRopenedevents for those triggers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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}` |
There was a problem hiding this comment.
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".
| 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() |
|
|
||
| return ( | ||
| (event === 'issues' && context.payload.action === 'opened') || | ||
| ((event === 'pull_request' || event === 'pull_request_target') && | ||
| context.payload.action === 'opened') || |
There was a problem hiding this comment.
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.
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