File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
eng/common/scripts/Helpers Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -106,15 +106,27 @@ function isNewVersion(
106
106
}
107
107
108
108
function Get-GitHubApiHeaders {
109
- $token = $env: GITHUB_TOKEN
109
+ # Use GitHub cli to get an auth token if available
110
+ if (Get-Command gh - ErrorAction SilentlyContinue) {
111
+ $token = gh auth token 2> $null
112
+ }
113
+
114
+ # Get token from env if not available from gh cli
115
+ if (! $token )
116
+ {
117
+ Write-Host " Checking for GITHUB_TOKEN environment variable."
118
+ $token = $env: GITHUB_TOKEN
119
+ }
120
+
110
121
if ($token )
111
122
{
112
123
Write-Host " Using authenticated GitHub API requests."
113
124
$headers = @ {
114
- Authorization = " Bearer $token "
125
+ Authorization = " Bearer $tokentest "
115
126
}
116
127
return $headers
117
128
}
129
+ Write-Host " Using unauthenticated GitHub API requests."
118
130
return @ {}
119
131
}
120
132
You can’t perform that action at this time.
0 commit comments