Skip to content

Commit e8c8d03

Browse files
mroeschkepooja-subramaniam
authored andcommitted
WEB/CI: Use GITHUB_TOKEN when making Github API calls (pandas-dev#50837)
1 parent cf93ee3 commit e8c8d03

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

web/pandas_web.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
import requests
4444
import yaml
4545

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+
4652

4753
class Preprocessors:
4854
"""
@@ -168,7 +174,9 @@ def maintainers_add_info(context):
168174
for user in (
169175
context["maintainers"]["active"] + context["maintainers"]["inactive"]
170176
):
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+
)
172180
if resp.status_code == 403:
173181
sys.stderr.write(
174182
"WARN: GitHub API quota exceeded when fetching maintainers\n"
@@ -199,7 +207,10 @@ def home_add_releases(context):
199207
context["releases"] = []
200208

201209
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+
)
203214
if resp.status_code == 403:
204215
sys.stderr.write("WARN: GitHub API quota exceeded when fetching releases\n")
205216
resp_bkp = requests.get(context["main"]["production_url"] + "releases.json")
@@ -275,7 +286,8 @@ def roadmap_pdeps(context):
275286
github_repo_url = context["main"]["github_repo_url"]
276287
resp = requests.get(
277288
"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,
279291
)
280292
if resp.status_code == 403:
281293
sys.stderr.write("WARN: GitHub API quota exceeded when fetching pdeps\n")

0 commit comments

Comments
 (0)