feat: add GitHub Actions OIDC detector#300
Conversation
Verified in a real GitHub Actions pipeline ✅Ran the detector end-to-end in a throwaway repo (cloudsmith-iduffy/cloudsmith-cli-oidc-test) that installs the CLI from this branch and runs OIDC auto-discovery against The new detector works as intended:
The only error in the run is on the Cloudsmith side, not in this code: That |
There was a problem hiding this comment.
Pull request overview
Adds GitHub Actions as a first-class OIDC auto-discovery environment for the CLI, enabling token exchange using the Actions runtime OIDC endpoint (and prioritizing it ahead of AWS detection when both could apply).
Changes:
- Implement a
GitHubActionsDetectorthat retrieves an OIDC JWT fromACTIONS_ID_TOKEN_REQUEST_URLusingACTIONS_ID_TOKEN_REQUEST_TOKEN, with configurable audience support. - Register the new detector ahead of the AWS detector in the OIDC environment detection chain.
- Add unit tests for detection and token retrieval behavior, and document GitHub Actions OIDC support in the README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Documents GitHub Actions OIDC auto-discovery behavior and links to setup docs. |
| cloudsmith_cli/core/tests/test_github_actions_detector.py | Adds unit tests covering env detection and request/audience/header construction. |
| cloudsmith_cli/core/credentials/oidc/detectors/github_actions.py | Implements the GitHub Actions OIDC detector and HTTP token retrieval. |
| cloudsmith_cli/core/credentials/oidc/detectors/init.py | Registers the GitHub Actions detector before the AWS detector. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add GitHub Actions to OIDC credential auto-discovery. When running in GitHub Actions with `id-token: write` permission, the CLI fetches an OIDC token from the Actions runtime endpoint and exchanges it for a Cloudsmith access token. Works out of the box with no extra dependencies. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4e8facf to
a8a533b
Compare
Summary
Adds a GitHub Actions environment detector to the OIDC credential auto-discovery chain, mirroring the existing AWS detector (#276). When running in GitHub Actions with
id-token: writepermission, the CLI fetches an OIDC JWT from the Actions runtime HTTP endpoint and exchanges it for a short-lived Cloudsmith API token.GITHUB_ACTIONS+ACTIONS_ID_TOKEN_REQUEST_URL/ACTIONS_ID_TOKEN_REQUEST_TOKENrequestssession and audience conventions from the AWS detector (self.context.oidc_audience or "cloudsmith")boto3)Testing
Unit tests cover detection (all env permutations), token extraction, URL/audience/header construction, custom audience, the
&separator when the request URL already has a query, and the missing-token error.Validated in a real GitHub Actions pipeline — see the comment below for the live run.
References:
🤖 Generated with Claude Code