Skip to content

Commit b79422b

Browse files
Added PR opening script (#88)
1 parent d7656c7 commit b79422b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

open-pullrequest.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param(
2+
[Parameter(Mandatory)]
3+
[string]
4+
$SourceBranch
5+
)
6+
7+
function Get-PullRequest() {
8+
$prInfo = (gh api -X GET repos/:owner/:repo/pulls -F head=":owner:$SourceBranch" -f state=open -f base=master | ConvertFrom-Json)
9+
return $prInfo.html_url
10+
}
11+
12+
$openedPR = Get-PullRequest
13+
14+
if ($openedPR.length -ne 0) {
15+
throw "A PR from $SourceBranch to master already exists."
16+
}
17+
18+
$buildUrl = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$env:SYSTEM_TEAMPROJECT/_build/results?buildId=$env:BUILD_BUILDID&_a=summary"
19+
$body = "This PR was auto-generated with [the localization pipeline build]($buildUrl)."
20+
21+
gh pr create --head $SourceBranch --title 'Localization update' --body $body
22+
23+
# Getting a link to the opened PR
24+
$env:PR_LINK = Get-PullRequest

0 commit comments

Comments
 (0)