Skip to content

Commit 257e9f4

Browse files
Use AuthToken for cal to Search API (#6624)
Co-authored-by: Chidozie Ononiwu <[email protected]>
1 parent 0676c77 commit 257e9f4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

eng/common/scripts/Helpers/ApiView-Helpers.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function Set-ApiViewCommentForRelatedIssues {
132132
. ${PSScriptRoot}\..\common.ps1
133133
$issuesForCommit = $null
134134
try {
135-
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish
135+
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish -AuthToken $AuthToken
136136
if ($issuesForCommit.items.Count -eq 0) {
137137
LogInfo "No issues found for commit: $HeadCommitish"
138138
Write-Host "##vso[task.complete result=SucceededWithIssues;]DONE"

eng/common/scripts/Invoke-GitHubAPI.ps1

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,17 @@ function Search-GitHubIssues {
560560
[ValidateNotNullOrEmpty()]
561561
[Parameter(Mandatory = $true)]
562562
$CommitHash,
563-
$State="open"
563+
$State="open",
564+
$AuthToken
564565
)
565566
$uri = "https://api.github.com/search/issues?q=sha:$CommitHash+state:$State"
566-
567-
return Invoke-RestMethod `
568-
-Method GET `
569-
-Uri $uri `
570-
-MaximumRetryCount 3
567+
$params = @{
568+
Method = 'GET'
569+
Uri = $uri
570+
MaximumRetryCount = 3
571+
}
572+
if ($AuthToken) {
573+
$params.Headers = Get-GitHubApiHeaders -token $AuthToken
574+
}
575+
return Invoke-RestMethod @params
571576
}

0 commit comments

Comments
 (0)