Use AuthToken for cal to Search API (#6624)

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
Azure SDK Bot 2025-06-11 19:55:38 -07:00 committed by GitHub
parent 0676c77217
commit 257e9f466a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

@ -132,7 +132,7 @@ function Set-ApiViewCommentForRelatedIssues {
. ${PSScriptRoot}\..\common.ps1
$issuesForCommit = $null
try {
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish -AuthToken $AuthToken
if ($issuesForCommit.items.Count -eq 0) {
LogInfo "No issues found for commit: $HeadCommitish"
Write-Host "##vso[task.complete result=SucceededWithIssues;]DONE"

View File

@ -560,12 +560,17 @@ function Search-GitHubIssues {
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$CommitHash,
$State="open"
$State="open",
$AuthToken
)
$uri = "https://api.github.com/search/issues?q=sha:$CommitHash+state:$State"
return Invoke-RestMethod `
-Method GET `
-Uri $uri `
-MaximumRetryCount 3
$params = @{
Method = 'GET'
Uri = $uri
MaximumRetryCount = 3
}
if ($AuthToken) {
$params.Headers = Get-GitHubApiHeaders -token $AuthToken
}
return Invoke-RestMethod @params
}