Use workload identity federation for Claude auth in CI workflows#984
Merged
Conversation
Replace the static ANTHROPIC_API_KEY secret with Workload Identity Federation inputs in claude.yml, claude-code-review.yml, claude-issue-triage.yml, and build-and-publish.yml. The federation rule, organization, service account, and workspace IDs are read from repository variables. Grant id-token: write where it was missing, including in the jobs of auto-release.yml and publish.yml that call the build-and-publish.yml reusable workflow.
MaxLeiter
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Switches this repository's Claude automation workflows from the static
ANTHROPIC_API_KEYsecret to Workload Identity Federation: the workflow's GitHub OIDC token is exchanged for a short-lived Claude API access token at runtime, so no long-lived API key needs to be stored in the repository.claude.ymlanthropic_api_key→ federation inputsclaude-code-review.ymlanthropic_api_key→ federation inputsclaude-issue-triage.ymlanthropic_api_key→ federation inputs, plusid-token: write(the other two already request it)build-and-publish.ymlanthropic_api_key→ federation inputs in the changelog step, plusid-token: writeon thepublishjobauto-release.yml,publish.ymlid-token: writeto the jobs that call thebuild-and-publish.ymlreusable workflow (a called workflow can only use permissions its caller grants)This uses the federation support shipped in anthropics/claude-code-action (
docs/setup.md#workload-identity-federation, anthropics/claude-code-action#1338).How it activates
The federation rule, organization, service account, and workspace IDs are read from repository variables (
vars.ANTHROPIC_FEDERATION_RULE_ID,vars.ANTHROPIC_ORGANIZATION_ID,vars.ANTHROPIC_SERVICE_ACCOUNT_ID,vars.ANTHROPIC_WORKSPACE_ID). These are identifiers, not credentials. Until a repo admin sets them, the action fails fast at env validation with a clear "authentication required" message — so this PR is safe to merge ahead of that, and switching over is a settings change rather than another PR.The
ANTHROPIC_API_KEYsecret is intentionally left in place until the federated path has produced green runs; rollback is reverting this PR.Behavior notes
claude-code-review.ymlruns onpull_request. Fork PRs don't receiveid-token: write(GitHub withholds it the same way it withholds secrets), so reviews continue to run only for same-repo PRs — identical to today's behavior with the secret.test.ymlis deliberately not migrated here: it passesANTHROPIC_API_KEYdirectly to pytest and todocker runfor the SDK under test. Migrating that path means mounting an identity token into the container rather than swapping a workflow input, so it needs its own treatment.