diff --git a/docs/configuration.md b/docs/configuration.md index e723f7347f1213633667ad3497070bce7cca29e5..41d19684bfe8bba75ec2a371be9dfedcf7c01f0c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -69,6 +69,7 @@ $ node renovate --help --recreate-closed [boolean] Recreate PRs even if same ones were closed previously --labels <list> Labels to add to Pull Request --assignees <list> Assignees for Pull Request + --reviewers <list> Requested reviewers for Pull Requests --log-level <string> Logging level Examples: @@ -118,4 +119,5 @@ Obviously, you can't set repository or package file location with this method. | `prBody` | Pull Request body template | string | `"This Pull Request updates dependency {{depName}} from version {{currentVersion}} to {{newVersion}}\n\n{{changelog}}"` | | | | `labels` | Labels to add to Pull Request | list | `[]` | `RENOVATE_LABELS` | `--labels` | | `assignees` | Assignees for Pull Request | list | `[]` | `RENOVATE_ASSIGNEES` | `--assignees` | +| `reviewers` | Requested reviewers for Pull Requests | list | `[]` | `RENOVATE_REVIEWERS` | `--reviewers` | | `logLevel` | Logging level | string | `"info"` | `LOG_LEVEL` | `--log-level` | diff --git a/lib/api/github.js b/lib/api/github.js index 3a47d88783e080c561dddfd061398d7eba65f4a8..9eebddef3647fdd8cdf29c8392456e1a16a7ea92 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -16,6 +16,7 @@ module.exports = { updateBranch, // issue addAssignees, + addReviewers, addLabels, // PR findPr, @@ -137,6 +138,18 @@ async function addAssignees(issueNo, assignees) { }); } +async function addReviewers(issueNo, reviewers) { + logger.debug(`Adding reviewers ${reviewers} to #${issueNo}`); + await ghGot.post(`repos/${config.repoName}/pulls/${issueNo}/requested_reviewers`, { + headers: { + accept: 'application/vnd.github.black-cat-preview+json', + }, + body: { + reviewers, + }, + }); +} + async function addLabels(issueNo, labels) { logger.debug(`Adding labels ${labels} to #${issueNo}`); await ghGot.post(`repos/${config.repoName}/issues/${issueNo}/labels`, { diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 4e319175a7197069d365e778c2d427670f17e6fb..c57c98c441d689381a25f382d46fb7e38737fa1d 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -110,6 +110,11 @@ const options = [ description: 'Assignees for Pull Request', type: 'list', }, + { + name: 'reviewers', + description: 'Requested reviewers for Pull Requests', + type: 'list', + }, // Debug options { name: 'logLevel', diff --git a/lib/worker.js b/lib/worker.js index da29ec9bde22be67a975566a36785f8438b9110d..f4ca3173fa893b1e67b1efa5b2d18a03c195eb07 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -253,6 +253,7 @@ async function updateDependency(upgrade) { const prNo = await createPr(); await addLabels(prNo); await addAssignees(prNo); + await addReviewers(prNo); return; } // Check if existing PR needs updating @@ -274,6 +275,15 @@ async function updateDependency(upgrade) { await github.addAssignees(prNo, config.assignees); } + // Add reviewers to a PR + async function addReviewers(prNo) { + if (config.reviewers.length === 0) { + logger.debug(`No reviewers to add to ${prNo}`); + return; + } + await github.addReviewers(prNo, config.reviewers); + } + // Add labels to a PR async function addLabels(prNo) { if (config.labels.length === 0) { diff --git a/readme.md b/readme.md index 8a1f20d5245b12e537743ac0fe50fc3e7d40b922..f0d86fcca1e8db3292b869ac312f02bda2cbd0c3 100644 --- a/readme.md +++ b/readme.md @@ -47,6 +47,7 @@ $ node renovate --help --recreate-closed [boolean] Recreate PRs even if same ones were closed previously --labels <list> Labels to add to Pull Request --assignees <list> Assignees for Pull Request + --reviewers <list> Requested reviewers for Pull Requests --log-level <string> Logging level Examples: