From b1bc0c61a9f1a3419194ffdef1cef95f2c505cef Mon Sep 17 00:00:00 2001 From: Egor Bryzgalov Date: Wed, 10 Mar 2021 16:23:13 +0300 Subject: [PATCH] Added PR opening script (#3302) * Added PR opening script (cherry picked from commit 14662d23b15c1258ee604dfdeddbb6517f704551) * Update open-pullrequest.ps1 --- open-pullrequest.ps1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 open-pullrequest.ps1 diff --git a/open-pullrequest.ps1 b/open-pullrequest.ps1 new file mode 100644 index 0000000000..25afaa84db --- /dev/null +++ b/open-pullrequest.ps1 @@ -0,0 +1,24 @@ +param( + [Parameter(Mandatory)] + [string] + $SourceBranch +) + +function Get-PullRequest() { + $prInfo = (gh api -X GET repos/:owner/:repo/pulls -F head=":owner:$SourceBranch" -f state=open -f base=master | ConvertFrom-Json) + return $prInfo.html_url +} + +$openedPR = Get-PullRequest + +if ($openedPR.length -ne 0) { + throw "A PR from $SourceBranch to master already exists." +} + +$buildUrl = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$env:SYSTEM_TEAMPROJECT/_build/results?buildId=$env:BUILD_BUILDID&_a=summary" +$body = "This PR was auto-generated with [the localization pipeline build]($buildUrl)." + +gh pr create --head $SourceBranch --title 'Localization update' --body $body + +# Getting a link to the opened PR +$env:PR_LINK = Get-PullRequest