Skip to content

Commit

Permalink
using GITHUB_TOKEN to make API requests in scripts/get_env.py (#4033)
Browse files Browse the repository at this point in the history
Co-authored-by: あく <[email protected]>
  • Loading branch information
ru-asdx and skotopes authored Dec 23, 2024
1 parent 626d7ef commit dc73096
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_compact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
env:
FBT_TOOLCHAIN_PATH: /runner/_work
FBT_GIT_SUBMODULE_SHALLOW: 1
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
compact:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
TARGETS: f7
DEFAULT_TARGET: f7
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
check-secret:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/merge_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
FBT_TOOLCHAIN_PATH: /runner/_work
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
merge_report:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pvs_studio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion scripts/get_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dc73096

Please sign in to comment.