42
42
import requests
43
43
import yaml
44
44
45
+ api_token = os .environ .get ("GITHUB_TOKEN" )
46
+ if api_token is not None :
47
+ GITHUB_API_HEADERS = {"Authorization" : f"Bearer { api_token } " }
48
+ else :
49
+ GITHUB_API_HEADERS = {}
50
+
45
51
46
52
class Preprocessors :
47
53
"""
@@ -166,7 +172,9 @@ def maintainers_add_info(context):
166
172
for kind in ("active" , "inactive" ):
167
173
context ["maintainers" ][f"{ kind } _with_github_info" ] = []
168
174
for user in context ["maintainers" ][kind ]:
169
- resp = requests .get (f"https://api.github.com/users/{ user } " )
175
+ resp = requests .get (
176
+ f"https://api.github.com/users/{ user } " , headers = GITHUB_API_HEADERS
177
+ )
170
178
if context ["ignore_io_errors" ] and resp .status_code == 403 :
171
179
return context
172
180
resp .raise_for_status ()
@@ -178,7 +186,10 @@ def home_add_releases(context):
178
186
context ["releases" ] = []
179
187
180
188
github_repo_url = context ["main" ]["github_repo_url" ]
181
- resp = requests .get (f"https://api.github.com/repos/{ github_repo_url } /releases" )
189
+ resp = requests .get (
190
+ f"https://api.github.com/repos/{ github_repo_url } /releases" ,
191
+ headers = GITHUB_API_HEADERS ,
192
+ )
182
193
if context ["ignore_io_errors" ] and resp .status_code == 403 :
183
194
return context
184
195
resp .raise_for_status ()
@@ -245,7 +256,8 @@ def roadmap_pdeps(context):
245
256
github_repo_url = context ["main" ]["github_repo_url" ]
246
257
resp = requests .get (
247
258
"https://api.github.com/search/issues?"
248
- f"q=is:pr is:open label:PDEP repo:{ github_repo_url } "
259
+ f"q=is:pr is:open label:PDEP repo:{ github_repo_url } " ,
260
+ headers = GITHUB_API_HEADERS ,
249
261
)
250
262
if context ["ignore_io_errors" ] and resp .status_code == 403 :
251
263
return context
0 commit comments