Skip to content

Commit b9af6cc

Browse files
committed
Document GitHub API rate limits and PAT usage
Update documentation to explain GitHub REST API rate limits and how to authenticate Evergreen requests. Added a new, expanded GitHub rate limit doc with guidance on creating personal access tokens, setting GITHUB_TOKEN/GH_TOKEN on Windows, macOS/Linux and in GitHub Actions, and how authentication raises the limit to 5,000 requests/hour. Clarified that Get-EvergreenApp and Update-Evergreen query GitHub (and may be rate limited), added verbose rate-limit output details, and linked relevant pages. Changes applied to docs/github.md, Get-EvergreenApp.md, Update-Evergreen.md, and issues.md.
1 parent 3285d95 commit b9af6cc

4 files changed

Lines changed: 92 additions & 13 deletions

File tree

docs/github.md

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,97 @@ layout: doc
33
---
44
# Working with GitHub rate limits
55

6-
Over 150 applications supported by Evergreen are hosted on GitHub repositories or pull data from a GitHub repository for determining the latest version. Evergreen makes use of the GitHub REST API when requesting details for these applications.
6+
Over 150 applications supported by Evergreen are hosted on GitHub repositories or pull data from a GitHub repository to determine the latest version. Evergreen uses the GitHub REST API when querying details for these applications.
77

8-
GitHub implements rate limits on the API for unauthenticated requests. See [Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) for details.
8+
Both `Get-EvergreenApp` and `Update-Evergreen` make requests to the GitHub REST API:
99

10-
## Authenticating to the GitHub API
10+
- `Get-EvergreenApp` queries GitHub releases and tags to return version and download details for applications hosted on GitHub
11+
- `Update-Evergreen` downloads the latest application functions and manifests from the [eucpilots/evergreen-apps](https://github.com/eucpilots/evergreen-apps) repository
1112

12-
For environments that may consume more than 60 requests to the API in an hour, Evergreen supports authenticated requests by use of [personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). [Fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) should be used.
13+
GitHub implements rate limits on the API for unauthenticated requests, allowing only 60 requests per hour per IP address. In environments where Evergreen is run frequently or across multiple sessions, this limit can be reached quickly. See [Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) for details.
1314

14-
A token that has read-only access to public repositories only is recommended. This should enable you to use a long expiry time; however, secure management of this token is recommended.
15+
Authenticating requests with a personal access token raises the limit to 5,000 requests per hour.
16+
17+
## Creating a personal access token
18+
19+
Evergreen supports authenticated requests using [personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). [Fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) are recommended.
20+
21+
A token with read-only access to public repositories is sufficient. No additional scopes or permissions are required. Because the token only needs read access to public repositories, a long expiry period is reasonable; however, secure management of the token is still recommended.
1522

1623
![Fine-grained personal access token](/img/github-pat.png)
1724

18-
## GITHUB_TOKEN environment variable
25+
## Setting the GITHUB_TOKEN environment variable
26+
27+
Evergreen reads the `GITHUB_TOKEN` or `GH_TOKEN` environment variables. Setting either variable with the value of the personal access token enables Evergreen to authenticate requests to the GitHub API automatically. Both `Get-EvergreenApp` and `Update-Evergreen` will use the token without any additional configuration.
28+
29+
### Windows
30+
31+
To set the variable for the current user persistently (survives across sessions and reboots):
32+
33+
```powershell
34+
[System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "<your-token>", "User")
35+
```
36+
37+
To set it for all users on the machine (requires administrator):
38+
39+
```powershell
40+
[System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "<your-token>", "Machine")
41+
```
42+
43+
The variable can also be set via **System Properties > Advanced > Environment Variables** in the Windows UI.
44+
45+
To set it only for the current PowerShell session:
46+
47+
```powershell
48+
$env:GITHUB_TOKEN = "<your-token>"
49+
```
50+
51+
### macOS and Linux
52+
53+
Add the following line to your shell profile (`~/.zshrc` for Zsh, `~/.bashrc` or `~/.bash_profile` for Bash) to set the variable persistently:
1954

20-
Evergreen will use the token stored in the `GITHUB_TOKEN` or `GH_TOKEN` environment variables. Setting either of these variables with the value of the personal access token will allow Evergreen to use the token when querying the GitHub API, significantly increasing the number of available requests.
55+
```bash
56+
export GITHUB_TOKEN="<your-token>"
57+
```
58+
59+
Reload the profile after saving:
2160

22-
### GitHub Actions
61+
```bash
62+
source ~/.zshrc # or source ~/.bashrc
63+
```
2364

24-
Additionally, if you are running Evergreen in a GitHub Actions workflow, the `GITHUB_TOKEN` will be used, so no additional personal access tokens are required - [Use GITHUB_TOKEN for authentication in workflows](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token).
65+
To set it only for the current shell session:
66+
67+
```bash
68+
export GITHUB_TOKEN="<your-token>"
69+
```
2570

26-
For example, add the following code to the top of your workflow file:
71+
## GitHub Actions
72+
73+
When running Evergreen in a GitHub Actions workflow, the `GITHUB_TOKEN` secret is automatically available and does not require a separate personal access token. See [Use GITHUB_TOKEN for authentication in workflows](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token).
74+
75+
Add the following to the top of your workflow file to make the token available as an environment variable:
2776

2877
```yaml
2978
# Environment variables
3079
env:
3180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3281
```
82+
83+
Evergreen will pick up the variable automatically when the workflow runs.
84+
85+
## Checking the rate limit status
86+
87+
When running `Get-EvergreenApp` for an application that uses GitHub as its source, passing `-Verbose` will output the current number of remaining API requests:
88+
89+
```powershell
90+
Get-EvergreenApp -Name "MicrosoftBicep" -Verbose
91+
```
92+
93+
The verbose output will include a line similar to:
94+
95+
```
96+
VERBOSE: Get-GitHubRateLimit: Remaining requests to the GitHub API: 58 of 60
97+
```
98+
99+
When the rate limit is exhausted, Evergreen returns a `RateLimited` version object and outputs a warning. Setting `GITHUB_TOKEN` or `GH_TOKEN` before running Evergreen will resolve this.

docs/help/en-US/Get-EvergreenApp.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ The output from this function can be passed to Where-Object to filter for a spec
2626

2727
`Get-EvergreenApp` uses official vendor sources including update APIs, web queries, and code repository locations to return details of a target application at run time.
2828

29+
Over 150 applications supported by Evergreen are hosted on GitHub. For these applications, `Get-EvergreenApp` queries the GitHub REST API, which is subject to a rate limit of 60 unauthenticated requests per hour. Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a personal access token to authenticate requests and raise the limit to 5,000 requests per hour.
30+
2931
## EXAMPLES
3032

3133
### EXAMPLE 1
@@ -250,6 +252,10 @@ Site: https://eucpilots.com/evergreen-docs
250252

251253
Author: Aaron Parker
252254

255+
For applications that use GitHub as a source, `Get-EvergreenApp` queries the GitHub REST API. Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a personal access token to authenticate these requests and avoid rate limiting. See [Working with GitHub rate limits](https://eucpilots.com/evergreen-docs/github/) for details.
256+
253257
## RELATED LINKS
254258

255259
[Use Evergreen](https://eucpilots.com/evergreen-docs/use/)
260+
261+
[Working with GitHub rate limits](https://eucpilots.com/evergreen-docs/github/)

docs/help/en-US/Update-Evergreen.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Update-Evergreen [-Force] [<CommonParameters>]
1919

2020
## DESCRIPTION
2121

22-
Enables separation of the core Evergreen module from app-specific code and manifests. Downloads the latest versions of /Apps and /Manifests from a specified GitHub repository to a user-writable location (no admin required). By default, the local cache is downloaded to %LocalAppData%\Evergreen on Windows, and ~/.evergreen on macOS and Linux.
22+
Enables separation of the core Evergreen module from app-specific code and manifests. Downloads the latest versions of /Apps and /Manifests from the [eucpilots/evergreen-apps](https://github.com/eucpilots/evergreen-apps) GitHub repository to a user-writable location (no admin required). By default, the local cache is downloaded to %LocalAppData%\Evergreen on Windows, and ~/.evergreen on macOS and Linux.
23+
24+
`Update-Evergreen` queries the GitHub REST API to check for and download updates. In environments where it is run frequently, GitHub's unauthenticated API rate limit of 60 requests per hour may be reached. Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a personal access token to authenticate requests and raise the limit to 5,000 requests per hour.
2325

2426
## EXAMPLES
2527

@@ -75,4 +77,8 @@ Site: https://eucpilots.com/evergreen-docs
7577
7678
Author: Aaron Parker
7779
80+
`Update-Evergreen` uses the GitHub REST API to check for and download updates from the eucpilots/evergreen-apps repository. Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a personal access token to authenticate these requests. See [Working with GitHub rate limits](https://eucpilots.com/evergreen-docs/github/) for details.
81+
7882
## RELATED LINKS
83+
84+
[Working with GitHub rate limits](https://eucpilots.com/evergreen-docs/github/)

docs/issues.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Supports Windows platforms only - this function wraps `Resolve-DnsName` which is
2121

2222
### Get-GitHubRepoRelease
2323

24-
`Get-GitHubRepoRelease` queries release information from a specified GitHub repository to return version and binaries or is used to source the version number for some applications. This function uses an unauthenticated session to the GitHub REST API, thus requests will be [rate limited]. Using the `-Verbose` parameter with `Get-EvergreenApp` for those applications that use GitHub as the source, will display the number of available requests to the API.
24+
`Get-GitHubRepoRelease` queries release information from a specified GitHub repository to return version and binaries or is used to source the version number for some applications. By default, requests to the GitHub REST API are unauthenticated and subject to a rate limit of 60 requests per hour. Using the `-Verbose` parameter with `Get-EvergreenApp` for those applications that use GitHub as the source will display the number of available API requests remaining.
2525

26-
Updating `Get-GitHubRepoRelease` to support authenticated requests is planned for a future release.
26+
Authenticated requests are supported via the `GITHUB_TOKEN` or `GH_TOKEN` environment variables, which raise the rate limit to 5,000 requests per hour. See [Working with GitHub rate limits](/github) for setup instructions.
2727

2828
## Application Functions
2929

0 commit comments

Comments
 (0)