Skip to content

Commit 4257c8e

Browse files
authored
Use workload identity federation for Claude auth in CI workflows (#1344)
Switch claude.yml, claude-review.yml, and issue-triage.yml from the anthropic_api_key secret to the workload identity federation inputs. The federation rule, organization, and service account IDs are read from repository variables; issue-triage.yml additionally gains the id-token: write permission required to request the OIDC token.
1 parent bbfaf8e commit 4257c8e

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/claude-review.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ jobs:
2020
- name: PR Review with Progress Tracking
2121
uses: anthropics/claude-code-action@v1
2222
with:
23-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
23+
# Authenticate to the Claude API via Workload Identity Federation
24+
# (the workflow's OIDC token is exchanged for a short-lived access
25+
# token) instead of a static API key. See docs/setup.md.
26+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
27+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
28+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
2429

2530
prompt: "/review-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}"
2631
claude_args: |

.github/workflows/claude.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ jobs:
3333
id: claude
3434
uses: anthropics/claude-code-action@main
3535
with:
36-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
36+
# Authenticate to the Claude API via Workload Identity Federation
37+
# (the workflow's OIDC token is exchanged for a short-lived access
38+
# token) instead of a static API key. See docs/setup.md.
39+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
40+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
41+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
3742
claude_args: |
3843
--allowedTools "Bash(bun install),Bash(bun test:*),Bash(bun run format),Bash(bun typecheck)"
3944
--model "claude-opus-4-7"

.github/workflows/issue-triage.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
permissions:
1212
contents: read
1313
issues: write
14+
# Required to mint the OIDC token that is exchanged for a Claude API
15+
# access token (Workload Identity Federation).
16+
id-token: write
1417

1518
steps:
1619
- name: Checkout repository
@@ -24,6 +27,11 @@ jobs:
2427
CLAUDE_CODE_SCRIPT_CAPS: '{"edit-issue-labels.sh":2}'
2528
with:
2629
prompt: "/label-issue REPO: ${{ github.repository }} ISSUE_NUMBER: ${{ github.event.issue.number }}"
27-
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
30+
# Authenticate to the Claude API via Workload Identity Federation
31+
# (the workflow's OIDC token is exchanged for a short-lived access
32+
# token) instead of a static API key. See docs/setup.md.
33+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
34+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
35+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
2836
allowed_non_write_users: "*" # Required for issue triage workflow, if users without repo write access create issues
2937
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)