Sync eng/common directory with azure-sdk-tools for PR 1091 (#790)

* Refactpr Submit Pull Request Script

* Refactor logic for interacting with Pull Requests

* Rework API Lib

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2020-10-16 13:06:31 -07:00 committed by GitHub
parent 843432172e
commit 50a1354aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 271 additions and 223 deletions

View File

@ -15,6 +15,7 @@ parameters:
ScriptDirectory: eng/common/scripts
GHReviewersVariable: ''
GHTeamReviewersVariable: ''
GHAssignessVariable: ''
# Multiple labels seperated by comma, e.g. "bug, APIView"
PRLabels: ''
SkipCheckingForChanges: false
@ -80,20 +81,7 @@ steps:
-AuthToken "$(azuresdk-github-pat)"
-PRTitle "${{ parameters.PRTitle }}"
-PRBody "${{ coalesce(parameters.PRBody, parameters.CommitMsg, parameters.PRTitle) }}"
-PRLabels "${{ parameters.PRLabels}}"
- task: PowerShell@2
displayName: Tag a Reviewer on PR
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
continueOnError: true
inputs:
pwsh: true
workingDirectory: ${{ parameters.WorkingDirectory }}
filePath: ${{ parameters.ScriptDirectory }}/add-pullrequest-reviewers.ps1
arguments: >
-RepoOwner "${{ parameters.RepoOwner }}"
-RepoName "$(RepoNameWithoutOwner)"
-AuthToken "$(azuresdk-github-pat)"
-GitHubUsers "$(${{ parameters.GHReviewersVariable }})"
-GitHubTeams "$(${{ parameters.GHTeamReviewersVariable }})"
-PRNumber "$(Submitted.PullRequest.Number)"
-PRLabels "${{ parameters.PRLabels }}"
-UserReviewers "${{ parameters.GHReviewersVariable }}"
-TeamReviewers "${{ parameters.GHTeamReviewersVariable }}"
-Assignees "${{ parameters.GHAssignessVariable }}"

View File

@ -19,10 +19,10 @@ param(
. "${PSScriptRoot}\common.ps1"
try {
Add-IssueComment -RepoOwner $RepoOwner -RepoName $RepoName `
Add-GithubIssueComment -RepoOwner $RepoOwner -RepoName $RepoName `
-IssueNumber $IssueNumber -Comment $Comment -AuthToken $AuthToken
}
catch {
LogError "Add-IssueComment failed with exception:`n$_"
LogError "Add-GithubIssueComment failed with exception:`n$_"
exit 1
}

View File

@ -19,10 +19,10 @@ param(
. "${PSScriptRoot}\common.ps1"
try {
Add-IssueLabels -RepoOwner $RepoOwner -RepoName $RepoName `
Add-GithubIssueLabels -RepoOwner $RepoOwner -RepoName $RepoName `
-IssueNumber $IssueNumber -Labels $Labels -AuthToken $AuthToken
}
catch {
LogError "Add-IssueLabels failed with exception:`n$_"
LogError "Add-GithubIssueLabels failed with exception:`n$_"
exit 1
}

View File

@ -9,10 +9,10 @@ param(
LogDebug "Operating on Repo [ $RepoName ]"
try{
$branches = (List-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix").ref
$branches = (Get-GitHubSourceReferences -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix").ref
}
catch {
LogError "List-References failed with exception:`n$_"
LogError "Get-GitHubSourceReferences failed with exception:`n$_"
exit 1
}
@ -22,11 +22,11 @@ foreach ($branch in $branches)
$branchName = $branch.Replace("refs/heads/","")
$head = "${RepoOwner}/${RepoName}:${branchName}"
LogDebug "Operating on branch [ $branchName ]"
$pullRequests = List-PullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head
$pullRequests = Get-GitHubPullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head
}
catch
{
LogError "List-PullRequests failed with exception:`n$_"
LogError "Get-GitHubPullRequests failed with exception:`n$_"
exit 1
}
@ -34,10 +34,10 @@ foreach ($branch in $branches)
{
LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated Pull Request. Deleting Branch"
try{
Delete-References -RepoOwner $RepoOwner -RepoName $RepoName -Ref ($branch.Remove(0,5)) -AuthToken $AuthToken
Remove-GitHubSourceReferences -RepoOwner $RepoOwner -RepoName $RepoName -Ref ($branch.Remove(0,5)) -AuthToken $AuthToken
}
catch {
LogError "Delete-References failed with exception:`n$_"
LogError "Remove-GitHubSourceReferences failed with exception:`n$_"
exit 1
}
}

View File

@ -0,0 +1,24 @@
param (
[Parameter(Mandatory = $true)]
[string]$RepoOwner,
[Parameter(Mandatory = $true)]
[string]$RepoName,
[Parameter(Mandatory = $true)]
$PullRequestNumber
)
. "${PSScriptRoot}\common.ps1"
try
{
$pullRequest = Get-GithubPullRequest -RepoOwner $RepoOwner -RepoName $RepoName -PullRequestNumber $PullRequestNumber
Write-Host "##vso[task.setvariable variable=System.PullRequest.Creator;]$($pullRequest.user.login)"
}
catch
{
Write-Error "Get-PullRequest failed with exception:`n$_"
exit 1
}

View File

@ -1,3 +1,7 @@
if ((Get-ChildItem -Path Function: | ? { $_.Name -eq "LogWarning" }).Count -eq 0) {
. "${PSScriptRoot}\logging.ps1"
}
$GithubAPIBaseURI = "https://api.github.com/repos"
function Get-GitHubHeaders ($token) {
@ -17,14 +21,26 @@ function Invoke-GitHubAPIPost {
$token
)
$resp = Invoke-RestMethod `
-Method POST `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
return $resp
try {
if ($body.Count -gt 0) {
$resp = Invoke-RestMethod `
-Method POST `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
return $resp
}
else {
throw "Did not fire request because of empty body."
}
}
catch {
$warning = "{0} with Uri [ $apiURI ] failed. `nBody: [ {1} ]" -f (Get-PSCallStack)[1].FunctionName , ($body | Out-String)
LogWarning $warning
throw
}
}
function Invoke-GitHubAPIPatch {
@ -37,14 +53,26 @@ function Invoke-GitHubAPIPatch {
$token
)
$resp = Invoke-RestMethod `
-Method PATCH `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
try {
if ($body.Count -gt 0) {
$resp = Invoke-RestMethod `
-Method PATCH `
-Body ($body | ConvertTo-Json) `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
return $resp
return $resp
}
else {
throw "Did not fire request because of empty body."
}
}
catch {
$warning = "{0} with Uri [ $apiURI ] failed. `nBody: [ {1} ]" -f (Get-PSCallStack)[1].FunctionName , ($body | Out-String)
LogWarning $warning
throw
}
}
function Invoke-GitHubAPIDelete {
@ -55,13 +83,20 @@ function Invoke-GitHubAPIDelete {
$token
)
$resp = Invoke-RestMethod `
try {
$resp = Invoke-RestMethod `
-Method DELETE `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
return $resp
return $resp
}
catch {
$warning = "{0} with Uri [ $apiURI ] failed." -f (Get-PSCallStack)[1].FunctionName
LogWarning $warning
throw
}
}
@ -72,31 +107,48 @@ function Invoke-GitHubAPIGet {
$token
)
if ($token)
{
$resp = Invoke-RestMethod `
-Method GET `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
try {
if ($token)
{
$resp = Invoke-RestMethod `
-Method GET `
-Uri $apiURI `
-Headers (Get-GitHubHeaders -token $token) `
-MaximumRetryCount 3
}
else {
$resp = Invoke-RestMethod `
-Method GET `
-Uri $apiURI `
-MaximumRetryCount 3
}
return $resp
}
else {
$resp = Invoke-RestMethod `
-Method GET `
-Uri $apiURI `
-MaximumRetryCount 3
catch {
$warning = "{0} with Uri [ $apiURI ] failed." -f (Get-PSCallStack)[1].FunctionName
LogWarning $warning
throw
}
return $resp
}
function SplitMembers ($membersString)
{
if (!$membersString) { return $null }
return @($membersString.Split(",") | % { $_.Trim() } | ? { return $_ })
function Set-GitHubAPIParameters ($members, $parameterName, $parameters, $allowEmptyMembers=$false) {
if ($null -ne $members) {
if ($members -is [array])
{
$parameters[$parameterName] = $members
}
else {
$memberAdditions = @($members.Split(",") | % { $_.Trim() } | ? { return $_ })
if (($memberAdditions.Count -gt 0) -or $allowEmptyMembers) {
$parameters[$parameterName] = $memberAdditions
}
}
}
return $parameters
}
function List-PullRequests {
function Get-GitHubPullRequests {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -109,18 +161,20 @@ function List-PullRequests {
[ValidateSet("created","updated","popularity","long-running")]
$Sort,
[ValidateSet("asc","desc")]
$Direction
$Direction,
[ValidateNotNullOrEmpty()]
$AuthToken
)
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/pulls"
if ($State -or $Head -or $Base -or $Sort -or $Direction) { $uri += '?'}
if ($State -or $Head -or $Base -or $Sort -or $Direction) { $uri += '?' }
if ($State) { $uri += "state=$State&" }
if ($Head) { $uri += "head=$Head&" }
if ($Base) { $uri += "base=$Base&" }
if ($Sort) { $uri += "sort=$Sort&" }
if ($Direction){ $uri += "direction=$Direction&" }
return Invoke-GitHubAPIGet -apiURI $uri
return Invoke-GitHubAPIGet -apiURI $uri -token $AuthToken
}
#
@ -129,22 +183,73 @@ function List-PullRequests {
Ref to search for
Pass 'heads/<branchame> ,tags/<tag name>, or nothing
#>
function List-References {
function Get-GitHubSourceReferences {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
[Parameter(Mandatory = $true)]
$RepoName,
$Ref
$Ref,
[ValidateNotNullOrEmpty()]
$AuthToken
)
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/git/matching-refs/"
if ($Ref) { $uri += "$Ref" }
return Invoke-GitHubAPIGet -apiURI $uri
return Invoke-GitHubAPIGet -apiURI $uri -token $AuthToken
}
function Add-IssueComment {
function Get-GitHubPullRequest {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
[Parameter(Mandatory = $true)]
$RepoName,
[Parameter(Mandatory = $true)]
$PullRequestNumber,
[ValidateNotNullOrEmpty()]
$AuthToken
)
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/pulls/$PullRequestNumber"
return Invoke-GitHubAPIGet -apiURI $uri -token $AuthToken
}
function New-GitHubPullRequest {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
[Parameter(Mandatory = $true)]
$RepoName,
[Parameter(Mandatory = $true)]
$Title,
[Parameter(Mandatory = $true)]
$Head,
[Parameter(Mandatory = $true)]
$Base,
$Body=$Title,
[Boolean]$Maintainer_Can_Modify=$false,
[Boolean]$Draft=$false,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
)
$parameters = @{
title = $Title
head = $Head
base = $Base
body = $Body
maintainer_can_modify = $Maintainer_Can_Modify
draft = $Draft
}
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/pulls"
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}
function Add-GitHubIssueComment {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -154,6 +259,7 @@ function Add-IssueComment {
$IssueNumber,
[Parameter(Mandatory = $true)]
$Comment,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
@ -168,7 +274,7 @@ function Add-IssueComment {
}
# Will add labels to existing labels on the issue
function Add-IssueLabels {
function Add-GitHubIssueLabels {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -179,27 +285,27 @@ function Add-IssueLabels {
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$Labels,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
)
if ($Labels.Trim().Length -eq 0)
{
throw "The 'Labels' parameter should not not be whitespace..`
You can use the 'Update-Issue' function if you plan to reset the labels"
throw " The 'Labels' parameter should not not be whitespace.
Use the 'Update-Issue' function if you plan to reset the labels"
}
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues/$IssueNumber/labels"
$labelAdditions = SplitMembers -membersString $Labels
$parameters = @{
labels = @($labelAdditions)
}
$parameters = @{}
$parameters = Set-GitHubAPIParameters -members $Labels -parameterName "labels" `
-parameters $parameters
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}
# Will add assignees to existing assignees on the issue
function Add-IssueAssignees {
function Add-GitHubIssueAssignees {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -210,28 +316,55 @@ function Add-IssueAssignees {
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$Assignees,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
)
if ($Assignees.Trim().Length -eq 0)
{
throw "The 'Assignees' parameter should not be whitespace.`
throw "The 'Assignees' parameter should not be whitespace.
You can use the 'Update-Issue' function if you plan to reset the Assignees"
}
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/issues/$IssueNumber/assignees"
$assigneesAdditions = SplitMembers -membersString $Assignees
$parameters = @{
assignees = @($assigneesAdditions)
}
$parameters = @{}
$parameters = Set-GitHubAPIParameters -members $Assignees -parameterName "assignees" `
-parameters $parameters
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}
function Add-GitHubPullRequestReviewers {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
[Parameter(Mandatory = $true)]
$RepoName,
[Parameter(Mandatory = $true)]
$PrNumber,
$Users,
$Teams,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
)
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/pulls/$PrNumber/requested_reviewers"
$parameters = @{}
$parameters = Set-GitHubAPIParameters -members $Users -parameterName "reviewers" `
-parameters $parameters
$parameters = Set-GitHubAPIParameters -members $Teams -parameterName "team_reviewers" `
-parameters $parameters
return Invoke-GitHubAPIPost -apiURI $uri -body $parameters -token $AuthToken
}
# For labels and assignee pass comma delimited string, to replace existing labels or assignees.
# Or pass white space " " to remove all labels or assignees
function Update-Issue {
function Update-GitHubIssue {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -244,10 +377,9 @@ function Update-Issue {
[ValidateSet("open","closed")]
[string]$State,
[int]$Milestome,
$Labels,
$Assignees,
[ValidateNotNullOrEmpty()]
[string]$Labels,
[ValidateNotNullOrEmpty()]
[string]$Assignees,
[Parameter(Mandatory = $true)]
$AuthToken
)
@ -258,19 +390,17 @@ function Update-Issue {
if ($Body) { $parameters["body"] = $Body }
if ($State) { $parameters["state"] = $State }
if ($Milestone) { $parameters["milestone"] = $Milestone }
if ($Labels) {
$labelAdditions = SplitMembers -membersString $Labels
$parameters["labels"] = @($labelAdditions)
}
if ($Assignees) {
$assigneesAdditions = SplitMembers -membersString $Assignees
$parameters["assignees"] = @($assigneesAdditions)
}
$parameters = Set-GitHubAPIParameters -members $Labels -parameterName "labels" `
-parameters $parameters -allowEmptyMembers $true
$parameters = Set-GitHubAPIParameters -members $Assignees -parameterName "assignees" `
-parameters $parameters -allowEmptyMembers $true
return Invoke-GitHubAPIPatch -apiURI $uri -body $parameters -token $AuthToken
}
function Delete-References {
function Remove-GitHubSourceReferences {
param (
[Parameter(Mandatory = $true)]
$RepoOwner,
@ -279,13 +409,14 @@ function Delete-References {
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$Ref,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$AuthToken
)
if ($Ref.Trim().Length -eq 0)
{
throw "You must supply a valid 'Ref' Parameter to 'Delete-Reference'."
throw "You must supply a valid 'Ref' Parameter to 'Delete-GithubSourceReferences'."
}
$uri = "$GithubAPIBaseURI/$RepoOwner/$RepoName/git/refs/$Ref"

View File

@ -48,87 +48,53 @@ param(
[Parameter(Mandatory = $false)]
[string]$PRBody = $PRTitle,
[Parameter(Mandatory = $false)]
[string]$PRLabels
[string]$PRLabels,
[string]$UserReviewers,
[string]$TeamReviewers,
[string]$Assignees
)
$headers = @{
Authorization = "bearer $AuthToken"
}
$query = "state=open&head=${PROwner}:${PRBranch}&base=${BaseBranch}"
function AddLabels([int] $prNumber, [string] $prLabelString, [array] $existingLabels)
{
# Adding labels to the pr.
if (-not $prLabelString) {
Write-Verbose "There are no labels added to the PR."
return
}
# Parse the labels from string to array
$prLabelArray = @($prLabelString.Split(",") | % { $_.Trim() } | ? { return $_ })
foreach ($label in $existingLabels) {
if ($prLabelArray -contains $label.name) {
continue
}
$prLabelArray += $label.name
}
$prLabelUri = "https://api.github.com/repos/$RepoOwner/$RepoName/issues/$prNumber"
$labelRequestData = @{
labels = $prLabelArray
}
try {
$resp = Invoke-RestMethod -Method PATCH -Headers $headers $prLabelUri -Body ($labelRequestData | ConvertTo-Json)
}
catch {
Write-Error "Invoke-RestMethod $prLabelUri failed with exception:`n$_"
}
$resp | Write-Verbose
Write-Host -f green "Label(s) [$prLabelArray] added to pull request: https://github.com/$RepoOwner/$RepoName/pull/$prNumber"
}
. "${PSScriptRoot}\common.ps1"
try {
$resp = Invoke-RestMethod -Headers $headers "https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query"
$resp = Get-GitHubPullRequests -RepoOwner $RepoOwner -RepoName $RepoName `
-Head "${PROwner}:${PRBranch}" -Base $BaseBranch
}
catch {
Write-Error "Invoke-RestMethod [https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query] failed with exception:`n$_"
LogError "Get-GitHubPullRequests failed with exception:`n$_"
exit 1
}
$resp | Write-Verbose
if ($resp.Count -gt 0) {
Write-Host -f green "Pull request already exists $($resp[0].html_url)"
# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp[0].number)"
AddLabels $resp[0].number $PRLabels $resp[0].labels
LogDebug "Pull request already exists $($resp[0].html_url)"
# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp[0].number)"
}
else {
$data = @{
title = $PRTitle
head = "${PROwner}:${PRBranch}"
base = $BaseBranch
body = $PRBody
maintainer_can_modify = $true
}
try {
$resp = Invoke-RestMethod -Method POST -Headers $headers `
"https://api.github.com/repos/$RepoOwner/$RepoName/pulls" `
-Body ($data | ConvertTo-Json)
$resp = New-GitHubPullRequest -RepoOwner $RepoOwner -RepoName $RepoName -Title $PRTitle `
-Head "${PROwner}:${PRBranch}" -Base $BaseBranch -Body $PRBody -Maintainer_Can_Modify $true `
-AuthToken $AuthToken
$resp | Write-Verbose
LogDebug "Pull request created https://github.com/$RepoOwner/$RepoName/pull/$($resp.number)"
# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp.number)"
Update-GitHubIssue -RepoOwner $RepoOwner -RepoName $RepoName -IssueNumber $resp.number `
-Labels $PRLabels -Assignees $Assignees -AuthToken $AuthToken
Add-GitHubPullRequestReviewers -RepoOwner $RepoOwner -RepoName $RepoName -PrNumber $resp.number `
-Users $UserReviewers -Teams $TeamReviewers -AuthToken $AuthToken
}
catch {
Write-Error "Invoke-RestMethod [https://api.github.com/repos/$RepoOwner/$RepoName/pulls] failed with exception:`n$_"
LogError "Call to GitHub API failed with exception:`n$_"
exit 1
}
$resp | Write-Verbose
Write-Host -f green "Pull request created https://github.com/$RepoOwner/$RepoName/pull/$($resp.number)"
# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp.number)"
AddLabels $resp.number $PRLabels $resp.labels
}

View File

@ -1,61 +0,0 @@
param(
[Parameter(Mandatory = $true)]
$RepoOwner,
[Parameter(Mandatory = $true)]
$RepoName,
[Parameter(Mandatory = $false)]
$GitHubUsers = "",
[Parameter(Mandatory = $false)]
$GitHubTeams = "",
[Parameter(Mandatory = $true)]
$PRNumber,
[Parameter(Mandatory = $true)]
$AuthToken
)
function AddMembers($memberName, $additionSet) {
$headers = @{
Authorization = "bearer $AuthToken"
}
$uri = "https://api.github.com/repos/$RepoOwner/$RepoName/pulls/$PRNumber/requested_reviewers"
$errorOccurred = $false
foreach ($id in $additionSet) {
try {
$postResp = @{}
$postResp[$memberName] = @($id)
$postResp = $postResp | ConvertTo-Json
Write-Host $postResp
$resp = Invoke-RestMethod -Method Post -Headers $headers -Body $postResp -Uri $uri -MaximumRetryCount 3
$resp | Write-Verbose
}
catch {
Write-Host "Error attempting to add $user `n$_"
$errorOccurred = $true
}
}
return $errorOccurred
}
# at least one of these needs to be populated
if (-not $GitHubUsers -and -not $GitHubTeams) {
Write-Host "No user provided for addition, exiting."
exit 0
}
$userAdditions = @($GitHubUsers.Split(",") | % { $_.Trim() } | ? { return $_ })
$teamAdditions = @($GitHubTeams.Split(",") | % { $_.Trim() } | ? { return $_ })
$errorsOccurredAddingUsers = AddMembers -memberName "reviewers" -additionSet $userAdditions
$errorsOccurredAddingTeams = AddMembers -memberName "team_reviewers" -additionSet $teamAdditions
if ($errorsOccurredAddingUsers -or $errorsOccurredAddingTeams) {
exit 1
}