-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to help approve eng-common PRs (#9006)
- Loading branch information
1 parent
da0cc37
commit 7ab4a4b
Showing
1 changed file
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[CmdletBinding(SupportsShouldProcess = $true)] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string] $engCommonSyncPRNumber | ||
|
||
) | ||
|
||
gh auth status | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
Write-Error "Please login via gh auth login" | ||
exit 1 | ||
} | ||
|
||
$ghloggedInUser = (gh api user -q .login) | ||
$engCommonToolsBranch = gh pr view $engCommonSyncPRNumber -R Azure/azure-sdk-tools --json "headRefName" --jq ".headRefName" | ||
|
||
if (!$engCommonToolsBranch) { | ||
Write-Error "Didn't find branch for PR $engCommonSyncPRNumber in Azure/azure-sdk-tools" | ||
exit 1 | ||
} | ||
|
||
# needs to remain in sync with \eng\pipelines\templates\stages\archetype-sdk-tool-repo-sync.yml | ||
$engCommonSyncBranch = "sync-eng/common-${engCommonToolsBranch}-${engCommonSyncPRNumber}" | ||
|
||
# needs to remain in sync with \eng\pipelines\eng-common-sync.yml | ||
$repos = @( | ||
"azure-sdk", | ||
"azure-sdk-for-android", | ||
"azure-sdk-for-c", | ||
"azure-sdk-for-cpp", | ||
"azure-sdk-for-go", | ||
"azure-sdk-for-ios", | ||
"azure-sdk-for-java", | ||
"azure-sdk-for-js", | ||
"azure-sdk-for-net", | ||
"azure-sdk-for-python" | ||
) | ||
|
||
foreach ($repo in $repos) | ||
{ | ||
$prstate = gh pr view $engCommonSyncBranch -R Azure/$repo --json "url,mergeable,mergeStateStatus,reviews" | ConvertFrom-Json | ||
|
||
Write-Host "PR: $($prstate.url) - " -NoNewline | ||
if ($prstate.reviews.author.login -notcontains $ghloggedInUser) { | ||
gh pr review $engCommonSyncBranch -R Azure/$repo --approve | ||
} | ||
else { | ||
Write-Host "Already approved" | ||
} | ||
if ($prstate.mergeStateStatus -ne "CLEAN") { | ||
Write-Host "****PR is not mergeable and may need to be manually merged." | ||
} | ||
} |