Skip to content

Commit 60ee2ec

Browse files
authored
Merge pull request #16253 from argotorg/fix_gh_rate_limit_on_circleci
Use a read-only GitHub token when retrieving PR information
2 parents 56686ce + ab3ab42 commit 60ee2ec

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ commands:
142142
FOUNDRY_REPO="foundry-rs/foundry"
143143
FOUNDRY_VERSION="<< parameters.version >>"
144144
# Make authenticated requests when the Github token is available
145-
if [[ -n "$GITHUB_ACCESS_TOKEN" ]]; then
146-
EXTRA_HEADERS=(--header 'Authorization: Bearer '"${GITHUB_ACCESS_TOKEN}")
145+
if [[ -n "$GITHUB_READ_TOKEN" ]]; then
146+
EXTRA_HEADERS=(--header 'Authorization: Bearer '"${GITHUB_READ_TOKEN}")
147147
fi
148148
FOUNDRY_RELEASE_SHA=$(curl \
149149
--silent \
@@ -1418,8 +1418,8 @@ jobs:
14181418
name: Retrieve EDR latest release tag
14191419
command: |
14201420
# Make authenticated requests when the Github token is available
1421-
if [[ -n "$GITHUB_ACCESS_TOKEN" ]]; then
1422-
EXTRA_HEADERS=(--header "Authorization: Bearer ${GITHUB_ACCESS_TOKEN}")
1421+
if [[ -n "$GITHUB_READ_TOKEN" ]]; then
1422+
EXTRA_HEADERS=(--header "Authorization: Bearer ${GITHUB_READ_TOKEN}")
14231423
fi
14241424
EDR_LATEST_RELEASE_TAG=$(
14251425
curl \

scripts/common/rest_api_helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ def __init__(self, project_slug: str, debug_requests: bool):
8484
self.debug_requests = debug_requests
8585

8686
def pull_request(self, pr_id: int) -> dict:
87+
# GITHUB_READ_TOKEN should be a PAT with read-only permissions
88+
# This is used by CircleCI and local scripts to avoid GitHub API rate limits
89+
headers = {'Authorization': f'Bearer {environ.get("GITHUB_READ_TOKEN")}'} if 'GITHUB_READ_TOKEN' in environ else {}
8790
return query_api(
8891
f'{self.BASE_URL}/repos/{self.project_slug}/pulls/{pr_id}',
8992
{},
90-
{},
93+
headers,
9194
self.debug_requests
9295
)
9396

0 commit comments

Comments
 (0)