You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use workload identity federation for Claude auth in CI workflows (#984)
## What
Switches this repository's Claude automation workflows from the static
`ANTHROPIC_API_KEY` secret to [Workload Identity
Federation](https://platform.claude.com/docs/en/manage-claude/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](https://github.com/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.
0 commit comments