Skip to content

Commit dd9ed4c

Browse files
ovitrifclaude
andcommitted
ci: add Claude GitHub App workflows
- claude.yml: @claude bot mentions in issues/PRs (org members only) - claude-code-review.yml: auto code review on PRs with --comment fix and --allowedTools for gh/git/read operations, plus old-comment minimization step Requires CLAUDE_CODE_OAUTH_TOKEN secret (set via GitHub App wizard). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 66810eb commit dd9ed4c

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
claude-review:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
issues: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 1
25+
26+
- name: Minimize old Claude comments
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
REPO="${{ github.repository }}"
31+
PR_NUMBER="${{ github.event.pull_request.number }}"
32+
33+
# Minimize issue comments from claude[bot]
34+
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "claude[bot]") | .node_id' | while read -r node_id; do
35+
if [ -n "$node_id" ]; then
36+
echo "Minimizing comment: $node_id"
37+
gh api graphql -f query='
38+
mutation($id: ID!) {
39+
minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) {
40+
minimizedComment { isMinimized }
41+
}
42+
}' -f id="$node_id" || true
43+
fi
44+
done
45+
46+
- name: Run Claude Code Review
47+
id: claude-review
48+
uses: anthropics/claude-code-action@v1
49+
with:
50+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
51+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
52+
plugins: 'code-review@claude-code-plugins'
53+
prompt: '/code-review:code-review --comment ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
54+
claude_args: |
55+
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git log:*),Bash(git diff:*),Bash(git blame:*),Read,Glob,Grep"

.github/workflows/claude.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
17+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
18+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
19+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
21+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)) ||
22+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
23+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association))
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write # Allow creating branches/commits
27+
pull-requests: write # Allow pushing to PR branches
28+
issues: write # Allow updating issue comments
29+
id-token: write
30+
actions: read # Required for Claude to read CI results on PRs
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v6
34+
with:
35+
fetch-depth: 0 # Full history for git operations
36+
37+
- name: Run Claude Code
38+
id: claude
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
42+
43+
# This is an optional setting that allows Claude to read CI results on PRs
44+
additional_permissions: |
45+
actions: read

0 commit comments

Comments
 (0)