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 script to help approve eng-common PRs #9006

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
54 changes: 54 additions & 0 deletions eng/scripts/Approve-Eng-Common-Sync-PRs.ps1
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."
}
}