Skip to content

Commit

Permalink
Required Review Action: omit author from reviewer assignment (#37653)
Browse files Browse the repository at this point in the history
This PR fixes a bug where the required-review action would attempt to
add the PR author as a reviewer if a matching rule was hit, however this
is no longer allowed by GitHub and would result in the error `Review
cannot be requested from pull request author.`. To avoid this, if
computed reviewers list includes the PR author, a message is logged and
they are filtered out of the list.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9318374096

Upstream-Ref: Automattic/jetpack@62f0e20
  • Loading branch information
anomiex authored and matticbot committed May 31, 2024
1 parent 4b41086 commit bc37113
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This is an alpha version! The changes listed here are not final.
### Changed
- Updated package dependencies.

### Fixed
- Don't request review from the PR author.

## [4.0.0] - 2024-02-07
### Added
- Added support for GitHub Enterprise by replacing github.com with a dynamic variable [#32974]
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36033,6 +36033,11 @@ async function requestReviewer( teams ) {
const owner = github.context.payload.repository.owner.login;
const repo = github.context.payload.repository.name;
const pr = github.context.payload.pull_request.number;
const author = `@${ github.context.payload.pull_request.user.login }`;
if ( teams.includes( author ) ) {
core.info( `Skipping review for author ${ author }` );
teams = teams.filter( team => team !== author );
}

const userReviews = [];
const teamReviews = [];
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/request-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ async function requestReviewer( teams ) {
const owner = github.context.payload.repository.owner.login;
const repo = github.context.payload.repository.name;
const pr = github.context.payload.pull_request.number;
const author = `@${ github.context.payload.pull_request.user.login }`;
if ( teams.includes( author ) ) {
core.info( `Skipping review for author ${ author }` );
teams = teams.filter( team => team !== author );
}

const userReviews = [];
const teamReviews = [];
Expand Down

0 comments on commit bc37113

Please sign in to comment.