Skip to content

Commit 2d39734

Browse files
committed
Use CI token for request to GitHub API
1 parent 4e3dd63 commit 2d39734

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

_static/.gitkeep

Whitespace-only changes.

conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

1717
# List all organization extensions
18+
import os
1819
import pathlib
1920
import requests
2021

2122
HERE = pathlib.Path(__file__).parent
2223
GET_REPOS = "https://api.github.com/orgs/jupyterlab-contrib/repos"
24+
TOKEN = os.getenv("GITHUB_TOKEN")
2325

2426
extensions = (HERE / "extensions.tpl").read_text()
27+
default_headers = {}
28+
if TOKEN is not None:
29+
default_headers["authorization"] = f"Bearer {TOKEN}"
30+
2531
try:
2632
repos = requests.get(
2733
GET_REPOS,
28-
headers={"Accept": "application/vnd.github.v3+json"},
34+
headers={**default_headers, "Accept": "application/vnd.github.v3+json"},
2935
params={"per_page": 100},
3036
)
3137
data = repos.json()
@@ -39,7 +45,10 @@
3945
try:
4046
readme = requests.get(
4147
repo["contents_url"].replace("{+path}", "README.md"),
42-
headers={"Accept": "application/vnd.github.VERSION.raw"},
48+
headers={
49+
**default_headers,
50+
"Accept": "application/vnd.github.VERSION.raw",
51+
},
4352
)
4453
filename = repo["name"]
4554
(HERE / (filename + ".md")).write_text(readme.text)

0 commit comments

Comments
 (0)