From 3fe729c471be646038215f80c9f64f654c226df3 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 18 Mar 2023 07:35:01 +0000 Subject: [PATCH] Query the GH Api authenticated if `GITHUB_TOKEN` env variable is available Signed-off-by: Pedro Algarvio --- tools/pkgrepo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/pkgrepo.py b/tools/pkgrepo.py index 1489f485ddb..733586fd99f 100644 --- a/tools/pkgrepo.py +++ b/tools/pkgrepo.py @@ -1305,7 +1305,12 @@ def _get_salt_releases(ctx: Context, repository: str) -> list[Version]: """ versions = set() with ctx.web as web: - web.headers.update({"Accept": "application/vnd.github+json"}) + headers = { + "Accept": "application/vnd.github+json", + } + if "GITHUB_TOKEN" in os.environ: + headers["Authorization"] = f"Bearer {os.environ['GITHUB_TOKEN']}" + web.headers.update(headers) ret = web.get(f"https://api.github.com/repos/{repository}/tags") if ret.status_code != 200: ctx.error(