1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

using GITHUB_TOKEN to make API requests in scripts/get_env.py (#4033)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
ru-asdx
2024-12-23 02:05:19 +00:00
committed by GitHub
parent 626d7ef509
commit dc73096966
6 changed files with 10 additions and 1 deletions

View File

@@ -34,7 +34,11 @@ def get_commit_json(event):
commit_url = event["pull_request"]["base"]["repo"]["commits_url"].replace(
"{/sha}", f"/{event['pull_request']['head']['sha']}"
)
with urllib.request.urlopen(commit_url, context=context) as commit_file:
request = urllib.request.Request(commit_url)
if "GH_TOKEN" in os.environ:
request.add_header("Authorization", "Bearer %s" % (os.environ["GH_TOKEN"]))
with urllib.request.urlopen(request, context=context) as commit_file:
commit_json = json.loads(commit_file.read().decode("utf-8"))
return commit_json