-
Notifications
You must be signed in to change notification settings - Fork 88
95 lines (87 loc) · 3.44 KB
/
Copy pathclaude-code.yml
File metadata and controls
95 lines (87 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Claude Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned, labeled]
pull_request_review:
types: [submitted]
env:
ACTIONS_RUNNER_DEBUG: true
jobs:
check-permissions:
name: Check permissions
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has-permission: ${{ steps.check.outputs.has-permission }}
steps:
- name: Check if user has write permissions
id: check
uses: actions/github-script@v7
with:
script: |
if (context.actor.endsWith('[bot]')) {
console.log(`Skipping permission check for ${context.actor}`);
core.setOutput('has-permission', true);
return true;
}
try {
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.actor
});
const hasWritePermission = ['admin', 'maintain', 'write'].includes(permission.permission);
console.log(`User ${context.actor} has permission: ${permission.permission}`);
core.setOutput('has-permission', hasWritePermission);
return hasWritePermission;
} catch (error) {
console.log(`Error checking permissions for ${context.actor}: ${error.message}`);
core.setOutput('has-permission', false);
return false;
}
claude-assistant:
name: Claude Assistant
needs: check-permissions
if: |
needs.check-permissions.outputs.has-permission == 'true' && (
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.labels.*.name, 'claude-action')))
)
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
submodules: true
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Claude Code Action
uses: anthropics/claude-code-action@beta
env:
NODE_VERSION: 23.9.0
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
timeout_minutes: "60"
disallowed_tools: "npm,yarn"
allowed_tools: "mcp__github__create_pull_request,Bash(forge build),Bash(forge test),Bash(forge test *),Bash(forge fmt),Bash(forge snapshot)"
custom_instructions: |
You MUST follow the development workflow described in CLAUDE.md.
You MUST open a draft pull request after creating a branch.
You MUST create a pull request after completing your task.
You can create pull requests using the `mcp__github__create_pull_request` tool.