1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 12:51:22 +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

@@ -12,6 +12,7 @@ env:
DEFAULT_TARGET: f7
FBT_TOOLCHAIN_PATH: /runner/_work
FBT_GIT_SUBMODULE_SHALLOW: 1
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
main:

View File

@@ -6,6 +6,7 @@ on:
env:
FBT_TOOLCHAIN_PATH: /runner/_work
FBT_GIT_SUBMODULE_SHALLOW: 1
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
compact:

View File

@@ -9,6 +9,7 @@ on:
env:
TARGETS: f7
DEFAULT_TARGET: f7
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check-secret:

View File

@@ -7,6 +7,7 @@ on:
env:
FBT_TOOLCHAIN_PATH: /runner/_work
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
merge_report:

View File

@@ -11,6 +11,7 @@ env:
DEFAULT_TARGET: f7
FBT_TOOLCHAIN_PATH: /runner/_work
FBT_GIT_SUBMODULE_SHALLOW: 1
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
analyse_c_cpp:

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