fix: use gh CLI and Bearer auth for setup action latest version fetch#1921
fix: use gh CLI and Bearer auth for setup action latest version fetch#1921
Conversation
The 'Test Action (Latest Version)' CI job fails with HTTP 403 when fetching the latest release via the GitHub API. The root cause is that the action uses 'Authorization: token' header format, which can be rejected on internal repositories. Fix: - Use gh CLI (pre-installed on runners) as primary method for resolving the latest release — it handles auth natively - Fall back to curl with the modern 'Authorization: Bearer' format and proper Accept/API-Version headers - Both approaches use the GITHUB_TOKEN already available in the env Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the composite setup action’s “latest release” resolution so it can fetch the latest version successfully for internal repositories (where the prior GitHub API auth header format triggered HTTP 403).
Changes:
- Switches “latest version” lookup to prefer
gh api ... --jq '.tag_name'(with native GitHub authentication handling). - Updates the curl fallback to use
Authorization: Bearerand adds recommended GitHub API headers (Accept,X-GitHub-Api-Version).
Show a summary per file
| File | Description |
|---|---|
action.yml |
Updates the release-version discovery logic and GitHub API authentication headers to avoid 403s on internal repos. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Smoke test results (run 24291085395)
Overall: PASS
|
🔬 Smoke Test Results
Overall: PARTIAL — GitHub API connectivity confirmed ✅; pre-computed step outputs were not injected into prompt. Author: @lpcox
|
Smoke Test: GitHub Actions Services Connectivity ✅
All checks passed. (
|
|
Smoke test matrix for PR #1921:
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Problem
The Test Action (Latest Version) CI job (run 24290945171) fails with:
The
action.ymlusesAuthorization: tokenwhen calling/repos/{owner}/{repo}/releases/latest, which returns HTTP 403 on internal repositories.Fix
gh apiCLI (pre-installed on all GitHub Actions runners) to resolve the latest release — it handles authentication nativelyAuthorization: Bearerformat with properAcceptandX-GitHub-Api-VersionheadersTesting
The
test-action.ymlworkflow runs automatically on this PR.