Skip to content

Commit 4ffdfb4

Browse files
ryan-williamsclaude
andcommitted
Fetch runner release without auth for fine-grained PAT compatibility
Fine-grained PATs can't access repos they weren't explicitly granted access to, even public ones like `actions/runner`. Use unauthenticated request instead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e4b46b5 commit 4ffdfb4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/lambda_gha/__main__.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
from os import environ
22

3+
import requests
34
from gha_runner.gh import GitHubInstance
45
from gha_runner.helper.input import EnvVarBuilder, check_required
56

7+
8+
def get_runner_release(platform: str = "linux", architecture: str = "x64") -> str:
9+
"""Fetch latest GitHub Actions runner release URL.
10+
11+
Uses unauthenticated request since fine-grained PATs can't access
12+
repos they weren't explicitly granted access to (even public ones).
13+
"""
14+
resp = requests.get("https://api.github.com/repos/actions/runner/releases/latest")
15+
resp.raise_for_status()
16+
release_data = resp.json()
17+
suffix = f"-{platform}-{architecture}-"
18+
for asset in release_data.get("assets", []):
19+
if suffix in asset["name"] and asset["name"].endswith(".tar.gz"):
20+
return asset["browser_download_url"]
21+
raise RuntimeError(f"Could not find {platform}-{architecture} runner release")
22+
623
from lambda_gha.defaults import (
724
DEFAULT_INSTANCE_TYPE,
825
DEFAULT_REGION,
@@ -27,11 +44,6 @@ def main():
2744
token = environ["GH_PAT"]
2845
api_key = environ["LAMBDA_API_KEY"]
2946

30-
# Debug token info (without revealing the actual token)
31-
print(f"GH_PAT length: {len(token)}")
32-
print(f"GH_PAT prefix: {token[:4]}..." if len(token) > 4 else f"GH_PAT too short: {len(token)}")
33-
print(f"GH_PAT has newline: {chr(10) in token or chr(13) in token}")
34-
3547
builder = (
3648
EnvVarBuilder(env)
3749
.update_state("INPUT_DEBUG", "debug")
@@ -78,7 +90,7 @@ def main():
7890
gh = GitHubInstance(token=token, repo=repo)
7991

8092
# Get runner release (Lambda instances are Linux x64)
81-
runner_release = gh.get_latest_runner_release(platform="linux", architecture="x64")
93+
runner_release = get_runner_release(platform="linux", architecture="x64")
8294
params["runner_release"] = runner_release
8395

8496
# Generate runner tokens

0 commit comments

Comments
 (0)