Allow test PRs in SubmitPullRequest.ps1 script, updates to Invoke-GitHubAPI (#810)
update Repos format Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
parent
d67bed6973
commit
89ecd9fe85
@ -19,6 +19,7 @@ parameters:
|
||||
# Multiple labels seperated by comma, e.g. "bug, APIView"
|
||||
PRLabels: ''
|
||||
SkipCheckingForChanges: false
|
||||
CloseAfterOpenForTesting: false
|
||||
|
||||
steps:
|
||||
|
||||
@ -63,7 +64,7 @@ steps:
|
||||
-CommitMsg "${{ parameters.CommitMsg }}"
|
||||
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/$(RepoNameWithoutOwner).git"
|
||||
-PushArgs "${{ parameters.PushArgs }}"
|
||||
-SkipCommit $${{parameters.SkipCheckingForChanges}}
|
||||
-SkipCommit $${{ parameters.SkipCheckingForChanges }}
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: Create pull request
|
||||
@ -85,3 +86,4 @@ steps:
|
||||
-UserReviewers "${{ parameters.GHReviewersVariable }}"
|
||||
-TeamReviewers "${{ parameters.GHTeamReviewersVariable }}"
|
||||
-Assignees "${{ parameters.GHAssignessVariable }}"
|
||||
-CloseAfterOpenForTesting $${{ parameters.CloseAfterOpenForTesting }}
|
||||
|
||||
@ -83,6 +83,7 @@ steps:
|
||||
GHReviewersVariable: ${{ parameters.GHReviewersVariable }}
|
||||
GHTeamReviewersVariable: ${{ parameters.GHTeamReviewersVariable }}
|
||||
PRLabels: ${{ parameters.PRLabels }}
|
||||
CloseAfterOpenForTesting: $(TestPipeline)
|
||||
|
||||
- ${{if ne( parameters['OnboardingBranch'], '')}}:
|
||||
- pwsh: |
|
||||
@ -122,4 +123,5 @@ steps:
|
||||
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
|
||||
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}
|
||||
GHReviewersVariable: ${{ parameters.GHReviewersVariable }}
|
||||
GHTeamReviewersVariable: ${{ parameters.GHTeamReviewersVariable }}
|
||||
GHTeamReviewersVariable: ${{ parameters.GHTeamReviewersVariable }}
|
||||
CloseAfterOpenForTesting: $(TestPipeline)
|
||||
|
||||
@ -33,7 +33,9 @@ function Invoke-GitHubAPIPost {
|
||||
return $resp
|
||||
}
|
||||
else {
|
||||
throw "Did not fire request because of empty body."
|
||||
$warning = "{0} with Uri [ $apiURI ] did not fire request because of empty body." -f (Get-PSCallStack)[1].FunctionName
|
||||
LogWarning $warning
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@ -65,7 +67,9 @@ function Invoke-GitHubAPIPatch {
|
||||
return $resp
|
||||
}
|
||||
else {
|
||||
throw "Did not fire request because of empty body."
|
||||
$warning = "{0} with Uri [ $apiURI ] did not fire request because of empty body." -f (Get-PSCallStack)[1].FunctionName
|
||||
LogWarning $warning
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
catch {
|
||||
|
||||
@ -54,7 +54,9 @@ param(
|
||||
|
||||
[string]$TeamReviewers,
|
||||
|
||||
[string]$Assignees
|
||||
[string]$Assignees,
|
||||
|
||||
[boolean]$CloseAfterOpenForTesting=$false
|
||||
)
|
||||
|
||||
. "${PSScriptRoot}\common.ps1"
|
||||
@ -87,11 +89,19 @@ else {
|
||||
# setting variable to reference the pull request by number
|
||||
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp.number)"
|
||||
|
||||
Update-GitHubIssue -RepoOwner $RepoOwner -RepoName $RepoName -IssueNumber $resp.number `
|
||||
-Labels $PRLabels -Assignees $Assignees -AuthToken $AuthToken
|
||||
|
||||
Add-GitHubPullRequestReviewers -RepoOwner $RepoOwner -RepoName $RepoName -PrNumber $resp.number `
|
||||
-Users $UserReviewers -Teams $TeamReviewers -AuthToken $AuthToken
|
||||
|
||||
if ($CloseAfterOpenForTesting) {
|
||||
$prState = "closed"
|
||||
LogDebug "Updating https://github.com/$RepoOwner/$RepoName/pull/$($resp.number) state to closed because this was only testing."
|
||||
}
|
||||
else {
|
||||
$prState = "open"
|
||||
}
|
||||
|
||||
Update-GitHubIssue -RepoOwner $RepoOwner -RepoName $RepoName -IssueNumber $resp.number `
|
||||
-State $prState -Labels $PRLabels -Assignees $Assignees -AuthToken $AuthToken
|
||||
}
|
||||
catch {
|
||||
LogError "Call to GitHub API failed with exception:`n$_"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user