Skip to content

Commit 44df5bd

Browse files
ovitrifclaude
andcommitted
feat: add Claude Code GitHub workflow
Add two GitHub Actions workflows for Claude Code integration: - claude.yml: PR assistant triggered by @claude mentions, gated to OWNER/MEMBER/COLLABORATOR with write permissions and full git history - claude-code-review.yml: Automated code review on PR events with concurrency control, old comment minimization, and restricted tools Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cda6400 commit 44df5bd

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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@v4
23+
with:
24+
fetch-depth: 1
25+
26+
- name: Minimize old Claude comments
27+
uses: actions/github-script@v7
28+
with:
29+
script: |
30+
const { data: comments } = await github.rest.issues.listComments({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
issue_number: context.payload.pull_request.number,
34+
per_page: 100,
35+
});
36+
const claudeComments = comments.filter(c =>
37+
c.user?.login === 'claude[bot]' || c.user?.login === 'github-actions[bot]'
38+
);
39+
for (const comment of claudeComments) {
40+
await github.graphql(`
41+
mutation MinimizeComment($id: ID!) {
42+
minimizeComment(input: { subjectId: $id, classifier: OUTDATED }) {
43+
minimizedComment { isMinimized }
44+
}
45+
}
46+
`, { id: comment.node_id });
47+
}
48+
49+
- name: Run Claude Code Review
50+
id: claude-review
51+
uses: anthropics/claude-code-action@v1
52+
with:
53+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
54+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
55+
plugins: 'code-review@claude-code-plugins'
56+
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
57+
allowed_bots: 'claude[bot]'
58+
claude_args: '--allowed-tools Bash(gh:*) WebFetch'

.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+
(github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')) ||
18+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
19+
(github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
21+
(github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'COLLABORATOR')) ||
22+
(github.event_name == 'issues' &&
23+
(contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
24+
(github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'COLLABORATOR'))
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
pull-requests: write
29+
issues: write
30+
id-token: write
31+
actions: read
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Run Claude Code
39+
id: claude
40+
uses: anthropics/claude-code-action@v1
41+
with:
42+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
43+
use_api_for_commits: true
44+
additional_permissions: |
45+
actions: read

0 commit comments

Comments
 (0)