Skip to content

Commit edaf3ef

Browse files
Set up claude (#17854)
Set up claude in ET repo
1 parent 5d4eff8 commit edaf3ef

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/claude-code.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened]
10+
11+
jobs:
12+
claude-code:
13+
# Early exit conditions (fast gate — avoids spinning up a runner for unauthorized users):
14+
# 1. Must be pytorch org
15+
# 2. Must mention @claude
16+
# 3. Must be org member/collaborator OR an allowed bot
17+
# Note: issue_comment and pull_request_review_comment share the same payload paths
18+
if: |
19+
github.repository_owner == 'pytorch' &&
20+
(
21+
(github.event_name != 'issues' &&
22+
contains(github.event.comment.body, '@claude') &&
23+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
24+
(github.event_name == 'issues' &&
25+
contains(github.event.issue.body, '@claude') &&
26+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association))
27+
)
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 60
30+
environment: bedrock
31+
permissions:
32+
contents: read
33+
pull-requests: write
34+
issues: write
35+
id-token: write
36+
steps:
37+
# Fork PR support enabled by using izaitsevfb/claude-code-action@forked-pr-fix
38+
39+
- uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 1
42+
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: '3.12'
47+
48+
- name: Install lintrunner
49+
run: |
50+
pip install lintrunner==0.12.5
51+
lintrunner init
52+
53+
- name: Configure AWS credentials via OIDC
54+
uses: aws-actions/configure-aws-credentials@v4
55+
with:
56+
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_claude_code
57+
aws-region: us-east-1
58+
59+
- name: Run Claude Code
60+
uses: izaitsevfb/claude-code-action@forked-pr-fix
61+
with:
62+
# We filter by github.actor at workflow level, there is no point of filtering here as well
63+
allowed_bots: "*"
64+
claude_args: "--model global.anthropic.claude-opus-4-6-v1"
65+
settings: '{"alwaysThinkingEnabled": true}'
66+
use_bedrock: "true"
67+
68+
- name: Upload usage metrics
69+
if: always()
70+
uses: pytorch/test-infra/.github/actions/upload-claude-usage@main

0 commit comments

Comments
 (0)