Open sultanberisa opened 12 months ago
You can authenticate to the GitHub API, and save the authentication token to $Env:GH_TOKEN
or $Env:GITHUB_TOKEN
. Evergreen will then use the token when querying the API, and you won't be rate limited.
See https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api
You can authenticate to the GitHub API, and save the authentication token to
$Env:GH_TOKEN
or$Env:GITHUB_TOKEN
. Evergreen will then use the token when querying the API, and you won't be rate limited.See https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api
Saving my Fine-grained personal access token into $Env:GH_TOKEN or $Env:GITHUB_TOKEN in PowerShell is not working. Still recieving rate limits
Same for me, got this today.
Not sure, but this part probably could be improved:
# If GITHUB_TOKEN or GH_TOKEN exists, let's add that to the API request
if (Test-Path -Path "env:GITHUB_TOKEN") {
$params.Headers = @{ Authorization = "token $env:GITHUB_TOKEN" }
}
elseif (Test-Path -Path "env:GH_TOKEN") {
$params.Headers = @{ Authorization = "token $env:GH_TOKEN" }
}
to something like this:
if ($env:GITHUB_TOKEN) {
$params.Headers = @{ Authorization = "token $env:GITHUB_TOKEN" }
}
elseif ($env:GH_TOKEN) {
$params.Headers = @{ Authorization = "token $env:GH_TOKEN" }
}
In my case current version didn't work as expected:
$env:GH_TOKEN="github_pat_1XXXX"
> Get-EvergreenApp -Name "AWSCLI" -Verbose
VERBOSE: Function path: C:\Users\admin\Documents\PowerShell\Modules\Evergreen\2407.1230\Apps\Get-AWSCLI.ps1
VERBOSE: Function exists: C:\Users\admin\Documents\PowerShell\Modules\Evergreen\2407.1230\Apps\Get-AWSCLI.ps1.
VERBOSE: Dot sourcing: C:\Users\admin\Documents\PowerShell\Modules\Evergreen\2407.1230\Apps\Get-AWSCLI.ps1.
VERBOSE: Get-FunctionResource: read application resource strings from [C:\Users\admin\Documents\PowerShell\Modules\Evergreen\2407.1230\Manifests\AWSCLI.json]
VERBOSE: Calling: Get-AWSCLI.
VERBOSE: Invoke-EvergreenWebRequest: Adding ContentType.
VERBOSE: Invoke-EvergreenWebRequest: Invoke-WebRequest parameter: UseBasicParsing: True.
VERBOSE: Invoke-EvergreenWebRequest: Invoke-WebRequest parameter: Uri: https://api.github.com/repos/aws/aws-cli/tags.
VERBOSE: Invoke-EvergreenWebRequest: Invoke-WebRequest parameter: ContentType: application/json; charset=utf-8.
VERBOSE: Invoke-EvergreenWebRequest: Invoke-WebRequest parameter: UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.2592.87.
VERBOSE: Invoke-EvergreenWebRequest: Invoke-WebRequest parameter: Method: Default.
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 281-byte response of content type application/json
WARNING: Invoke-EvergreenWebRequest: Response status code does not indicate success: 403 (rate limit exceeded)., with: https://api.github.com/repos/aws/aws-cli/tags.
WARNING: Invoke-EvergreenWebRequest: For troubleshooting steps see: https://stealthpuppy.com/evergreen/troubleshoot/.
WARNING: Run 'Get-EvergreenApp -Name "AWSCLI" -Verbose' to review additional details for troubleshooting.
Invoke-WebRequest: C:\Users\admin\Documents\PowerShell\Modules\Evergreen\2407.1230\Private\Invoke-EvergreenWebRequest.ps1:123
Line |
123 | $Response = Invoke-WebRequest @params
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| { "message": "API rate limit exceeded for 147.161.248.199. (But here\u0027s the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", "documentation_url":
| "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting" }
AWSCLI
isn't using the internal Get-GitHubRepoRelease
function which supports tokens. I'll have to update that app
What happened?
I am building an automated packaging workflow using evergreen. At some point, i noticed that my variable which would hold the download url which is dynamically retrieved via evergreen, was null. Upon checking closer i can see that i get ratelimited:
How can i avoid this / solve this somehow? If i get ratelimited during a workflow it would be pretty stupid and would require manual action, thus removing the whole point of the "workflow" haha
Version
2309.840
What PowerShell edition/s are you running Evergreen on?
Windows PowerShell
Which operating system/s are you running Evergreen on?
Windows 10+
Have you reviewed the documentation?
Verbose output