|
43 | 43 | import requests
|
44 | 44 | import yaml
|
45 | 45 |
|
| 46 | +api_token = os.environ.get("GITHUB_TOKEN") |
| 47 | +if api_token is not None: |
| 48 | + GITHUB_API_HEADERS = {"Authorization": f"Bearer {api_token}"} |
| 49 | +else: |
| 50 | + GITHUB_API_HEADERS = {} |
| 51 | + |
46 | 52 |
|
47 | 53 | class Preprocessors:
|
48 | 54 | """
|
@@ -168,7 +174,9 @@ def maintainers_add_info(context):
|
168 | 174 | for user in (
|
169 | 175 | context["maintainers"]["active"] + context["maintainers"]["inactive"]
|
170 | 176 | ):
|
171 |
| - resp = requests.get(f"https://api.github.com/users/{user}") |
| 177 | + resp = requests.get( |
| 178 | + f"https://api.github.com/users/{user}", headers=GITHUB_API_HEADERS |
| 179 | + ) |
172 | 180 | if resp.status_code == 403:
|
173 | 181 | sys.stderr.write(
|
174 | 182 | "WARN: GitHub API quota exceeded when fetching maintainers\n"
|
@@ -199,7 +207,10 @@ def home_add_releases(context):
|
199 | 207 | context["releases"] = []
|
200 | 208 |
|
201 | 209 | github_repo_url = context["main"]["github_repo_url"]
|
202 |
| - resp = requests.get(f"https://api.github.com/repos/{github_repo_url}/releases") |
| 210 | + resp = requests.get( |
| 211 | + f"https://api.github.com/repos/{github_repo_url}/releases", |
| 212 | + headers=GITHUB_API_HEADERS, |
| 213 | + ) |
203 | 214 | if resp.status_code == 403:
|
204 | 215 | sys.stderr.write("WARN: GitHub API quota exceeded when fetching releases\n")
|
205 | 216 | resp_bkp = requests.get(context["main"]["production_url"] + "releases.json")
|
@@ -275,7 +286,8 @@ def roadmap_pdeps(context):
|
275 | 286 | github_repo_url = context["main"]["github_repo_url"]
|
276 | 287 | resp = requests.get(
|
277 | 288 | "https://api.github.com/search/issues?"
|
278 |
| - f"q=is:pr is:open label:PDEP repo:{github_repo_url}" |
| 289 | + f"q=is:pr is:open label:PDEP repo:{github_repo_url}", |
| 290 | + headers=GITHUB_API_HEADERS, |
279 | 291 | )
|
280 | 292 | if resp.status_code == 403:
|
281 | 293 | sys.stderr.write("WARN: GitHub API quota exceeded when fetching pdeps\n")
|
|
0 commit comments