Skip to content

Commit bd02649

Browse files
authored
[devops] Improve detection of CI builds to not find any PRs for them. (#22499)
Example comment where we got it wrong: #22498 (comment) The comment is not for a PR, but for a CI build: c90957b, but since the PR contains the actual commit, it got reported there.
1 parent 9bf9a88 commit bd02649

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tools/devops/automation/scripts/GitHub.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@ function Get-GitHubPRsForHash {
884884

885885
Write-Host "Getting related PR ids for commit $Hash"
886886

887+
$prs = [System.Collections.ArrayList]@()
888+
if ($Env:IS_PR -eq "false") {
889+
Write-Host "This isn't a PR, IS_PR=false"
890+
return $prs
891+
}
892+
887893
if ($Org -and $Repo) {
888894
$url = "https://api.github.com/repos/$($Org)/$($Repo)/commits/$Hash/pulls"
889895
} else {
@@ -902,7 +908,6 @@ function Get-GitHubPRsForHash {
902908
Write-Host "Request result: $request"
903909

904910
# loop over the result and remove all the extra noise we are not interested in
905-
$prs = [System.Collections.ArrayList]@()
906911
foreach ($prInfo in $request) {
907912
$state = $prInfo.state
908913
if ($state -ne "open") {

tools/devops/automation/templates/tests/publish-html.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ steps:
8787
TESTS_JOBSTATUS: $(TESTS_JOBSTATUS) # set by the runTests step
8888
TESTS_SUMMARY: $(TEST_SUMMARY_PATH)
8989
ACCESSTOKEN: $(System.AccessToken)
90+
IS_PR: ${{ parameters.isPR }}
9091
${{ if eq(parameters.repositoryAlias, 'self') }}:
9192
COMMENT_HASH: $(fix_commit.GIT_HASH)
9293
${{ else }}:

0 commit comments

Comments
 (0)