Skip to content

Commit

Permalink
Added PR opening script (#3302)
Browse files Browse the repository at this point in the history
* Added PR opening script

(cherry picked from commit 14662d2)

* Update open-pullrequest.ps1
  • Loading branch information
egor-bryzgalov committed Mar 10, 2021
1 parent 7ffe334 commit b1bc0c6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions open-pullrequest.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b1bc0c6

Please sign in to comment.