Skip to content

Commit 5de094e

Browse files
try to use token for authenticated access to GitHub REST API
1 parent 2a4be3d commit 5de094e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.github/workflows/pro-integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
run:
4848
working-directory: localstack-ext
4949
environment: localstack-ext-tests
50+
env:
51+
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} # used for increased rate-limits when installing packages
5052
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository # skip job if fork PR
5153
steps:
5254
- name: Determine companion-ref

localstack/packages/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ def __init__(self, name: str, tag: str, github_slug: str):
142142
@lru_cache()
143143
def _get_download_url(self) -> str:
144144
asset_name = self._get_github_asset_name()
145-
response = requests.get(self.github_tag_url)
145+
# try to use a token when calling the GH API for increased API rate limits
146+
headers = None
147+
gh_token = os.environ.get("GITHUB_API_TOKEN")
148+
if gh_token:
149+
headers = {"authorization": f"Bearer {gh_token}"}
150+
response = requests.get(self.github_tag_url, headers=headers)
146151
if not response.ok:
147152
raise PackageException(
148153
f"Could not get list of releases from {self.github_tag_url}: {response.text}"

0 commit comments

Comments
 (0)