Skip to content

Use workload identity federation for Claude auth in CI workflows#984

Merged
ashwin-ant merged 1 commit into
mainfrom
ci-wif-auth
May 22, 2026
Merged

Use workload identity federation for Claude auth in CI workflows#984
ashwin-ant merged 1 commit into
mainfrom
ci-wif-auth

Conversation

@ashwin-ant

Copy link
Copy Markdown
Collaborator

What

Switches this repository's Claude automation workflows from the static ANTHROPIC_API_KEY secret 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.

Workflow Change
claude.yml anthropic_api_key → federation inputs
claude-code-review.yml anthropic_api_key → federation inputs
claude-issue-triage.yml anthropic_api_key → federation inputs, plus id-token: write (the other two already request it)
build-and-publish.yml anthropic_api_key → federation inputs in the changelog step, plus id-token: write on the publish job
auto-release.yml, publish.yml grant id-token: write to the jobs that call the build-and-publish.yml reusable 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_KEY secret is intentionally left in place until the federated path has produced green runs; rollback is reverting this PR.

Behavior notes

  • claude-code-review.yml runs on pull_request. Fork PRs don't receive id-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.yml is deliberately not migrated here: it passes ANTHROPIC_API_KEY directly to pytest and to docker run for 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.

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.
@ashwin-ant ashwin-ant merged commit 3471a9f into main May 22, 2026
16 checks passed
@ashwin-ant ashwin-ant deleted the ci-wif-auth branch May 22, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants