Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Additional Reviewers Argument #438

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ Controls whether to copy the requested reviewers from the original pull request
Note that this does not request reviews from those users who already reviewed the original pull request.
By default, the requested reviewers are not copied.

### `additional_reviewers`

Default: `''` (disabled)

Comma-separated list of GitHub usernames to add as reviewers to the backport pull request.

### `experimental`

Default:
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ inputs:
Note that this does not request reviews from those users who already reviewed the original pull request.
By default, the requested reviewers are not copied.
default: false
additional_reviewers:
description: >
Comma-separated list of GitHub usernames to add as reviewers to the backport pull request.
By default, no additional reviewers are added.
experimental:
description: >
Configure experimental features by passing a JSON object.
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ function run() {
const copy_assignees = core.getInput("copy_assignees");
const copy_milestone = core.getInput("copy_milestone");
const copy_requested_reviewers = core.getInput("copy_requested_reviewers");
const additional_reviewers = core.getInput("additional_reviewers");
const experimental = JSON.parse(core.getInput("experimental"));
const source_pr_number = core.getInput("source_pr_number");
if (cherry_picking !== "auto" && cherry_picking !== "pull_request_head") {
Expand Down Expand Up @@ -1126,6 +1127,7 @@ function run() {
copy_assignees: copy_assignees === "true",
copy_milestone: copy_milestone === "true",
copy_requested_reviewers: copy_requested_reviewers === "true",
additional_reviewers: additional_reviewers === "" ? undefined : additional_reviewers.split(","),
experimental: Object.assign(Object.assign({}, backport_1.experimentalDefaults), experimental),
source_pr_number: source_pr_number === "" ? undefined : parseInt(source_pr_number),
};
Expand Down
36 changes: 20 additions & 16 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type Config = {
copy_milestone: boolean;
copy_assignees: boolean;
copy_requested_reviewers: boolean;
additional_reviewers: string[];
experimental: Experimental;
};

Expand Down Expand Up @@ -418,23 +419,26 @@ export class Backport {
}
}

let reviewers: string [] = this.config.additional_reviewers || []
if (this.config.copy_requested_reviewers == true) {
const reviewers = mainpr.requested_reviewers?.map(
(reviewer) => reviewer.login,
);
if (reviewers?.length > 0) {
console.info("Setting reviewers " + reviewers);
const reviewRequest = {
owner,
repo,
pull_number: new_pr.number,
reviewers: reviewers,
};
const set_reviewers_response =
await this.github.requestReviewers(reviewRequest);
if (set_reviewers_response.status != 201) {
console.error(JSON.stringify(set_reviewers_response));
}
const requested_reviewers = mainpr.requested_reviewers?.map(
(reviewer) => reviewer.login,
) || [];
reviewers = reviewers.concat(requested_reviewers)
}
reviewers = [...new Set(reviewers)];
if (reviewers?.length > 0) {
console.info("Setting reviewers " + reviewers);
const reviewRequest = {
owner,
repo,
pull_number: new_pr.number,
reviewers: reviewers,
};
const set_reviewers_response =
await this.github.requestReviewers(reviewRequest);
if (set_reviewers_response.status != 201) {
console.error(JSON.stringify(set_reviewers_response));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async function run(): Promise<void> {
const copy_assignees = core.getInput("copy_assignees");
const copy_milestone = core.getInput("copy_milestone");
const copy_requested_reviewers = core.getInput("copy_requested_reviewers");
const additional_reviewers = core.getInput("additional_reviewers");
const experimental = JSON.parse(core.getInput("experimental"));
const source_pr_number = core.getInput("source_pr_number");

Expand Down Expand Up @@ -85,6 +86,7 @@ async function run(): Promise<void> {
copy_assignees: copy_assignees === "true",
copy_milestone: copy_milestone === "true",
copy_requested_reviewers: copy_requested_reviewers === "true",
additional_reviewers: additional_reviewers === "" ? undefined : additional_reviewers.split(","),
experimental: { ...experimentalDefaults, ...experimental },
source_pr_number:
source_pr_number === "" ? undefined : parseInt(source_pr_number),
Expand Down