forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools repository for Tools P…
…R 1041 (Azure#11454)
- Loading branch information
1 parent
23c9e1a
commit 5e3f453
Showing
4 changed files
with
109 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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 | ||
} |
This file was deleted.
Oops, something went wrong.