diff --git a/README.md b/README.md index 66197c7..eb0f058 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,6 @@ Contributions welcome. Prototype (min required to do load testing): -- github token for github api requests -- set requests otherwise requests is same as limits ? - plug it on a bunch of OCA and shopinvader repos to test load - configuring many repos in a .env file may be difficult, switch to a toml file ? diff --git a/src/runboat/github.py b/src/runboat/github.py index dfa2cd9..717fc9c 100644 --- a/src/runboat/github.py +++ b/src/runboat/github.py @@ -4,6 +4,7 @@ from typing import Any import requests from .exceptions import NotFoundOnGithub +from .settings import settings def _github_get(url: str) -> Any: @@ -12,6 +13,8 @@ def _github_get(url: str) -> Any: headers = { "Accept": "application/vnd.github.v3+json", } + if settings.github_token: + headers["Authorization"] = f"token {settings.github_token}" response = requests.get(full_url, headers) if response.status_code == 404: raise NotFoundOnGithub(f"GitHub URL not found: {full_url}.") diff --git a/src/runboat/settings.py b/src/runboat/settings.py index 3981b5d..42c34d0 100644 --- a/src/runboat/settings.py +++ b/src/runboat/settings.py @@ -1,3 +1,5 @@ +from typing import Optional + from pydantic import BaseSettings @@ -15,6 +17,7 @@ class Settings(BaseSettings): build_pgpassword: str build_admin_passwd: str build_domain: str + github_token: Optional[str] class Config: env_prefix = "RUNBOAT_"