Skip to content

Commit 561858d

Browse files
Use GITHUB_TOKEN for GitHub API requests to avoid rate limiting
1 parent b4b8c66 commit 561858d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

install.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ SHELL_HOOK_SCRIPT_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/H
2121
POST_CHECKOUT_HOOK_PATH="$TOOL_DIR/post-checkout"
2222
POST_CHECKOUT_HOOK_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/HEAD/post-checkout"
2323

24+
# =============================================================================
25+
# GITHUB API AUTHENTICATION
26+
# =============================================================================
27+
28+
# Build curl options for GitHub API requests.
29+
# If GITHUB_TOKEN is set, include it as a Bearer token to avoid rate limiting
30+
# (5000 req/hr authenticated vs. 60 req/hr unauthenticated).
31+
CURL_GITHUB_API_OPTS=()
32+
if [ -n "${GITHUB_TOKEN:-}" ]; then
33+
CURL_GITHUB_API_OPTS=(-H "Authorization: Bearer $GITHUB_TOKEN")
34+
echo "Using GITHUB_TOKEN for authenticated GitHub API requests"
35+
fi
36+
2437
# =============================================================================
2538
# TOOL VERSION DETECTION
2639
# =============================================================================
@@ -29,7 +42,7 @@ POST_CHECKOUT_HOOK_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/
2942
if [ ! -f "$VERSION_FILE" ]; then
3043
echo "Missing $VERSION_FILE. Fetching the latest version"
3144
# Fetch latest release version from GitHub API
32-
REQUIRED_EXECUTABLE_VERSION=$(curl -LSsf "https://api.github.com/repos/$ORGANIZATION/$TOOL_NAME/releases/latest" | grep '"tag_name":' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
45+
REQUIRED_EXECUTABLE_VERSION=$(curl -LSsf "${CURL_GITHUB_API_OPTS[@]}" "https://api.github.com/repos/$ORGANIZATION/$TOOL_NAME/releases/latest" | grep '"tag_name":' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
3346

3447
if [ -z "$REQUIRED_EXECUTABLE_VERSION" ]; then
3548
echo "ERROR: Could not fetch latest version from $REPOSITORY_URL"
@@ -158,7 +171,6 @@ fi
158171
echo "📥 Downloading $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION)..."
159172

160173
# Download the appropriate version for the detected OS
161-
# Use the updated URL pointing to the new S3 bucket
162174
curl -LSsf --output "./$TEMP_EXECUTABLE_ZIP_FILENAME" \
163175
"$REPOSITORY_URL/releases/download/$REQUIRED_EXECUTABLE_VERSION/$TEMP_EXECUTABLE_ZIP_FILENAME"
164176

0 commit comments

Comments
 (0)