-
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (88 loc) · 3.76 KB
/
claude-code-bot.yml
File metadata and controls
90 lines (88 loc) · 3.76 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
---
name: Mention bot using Claude Code
on:
# issue_comment:
# types:
# - created
# pull_request_review_comment:
# types:
# - created
# pull_request_review:
# types:
# - submitted
# issues:
# types:
# - opened
# - assigned
workflow_call:
inputs:
claude-args:
required: false
type: string
description: Additional arguments to pass directly to Claude Code Action
default: '--allowed-tools "Bash(gh:*)",mcp__github_inline_comment__create_inline_comment --model "opus"'
runs-on:
required: false
type: string
description: Runner to use
default: ubuntu-latest
secrets:
CLAUDE_CODE_OAUTH_TOKEN:
required: false
description: OAuth token for Claude Code
GH_TOKEN:
required: false
description: GitHub token for accessing the repository
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
actions: read # Required for Claude to read CI results on PRs
jobs:
claude-code-bot:
if: >
(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.title, '@claude')))
runs-on: ${{ inputs.runs-on }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} # zizmor: ignore[secrets-outside-env] caller-provided secret
persist-credentials: true
- name: Deploy agents and commands from claude-code-action
env:
CLAUDE_CODE_ACTION_ROOT: ${{ github.workspace }}/../../_actions/anthropics/claude-code-action
run: |
if [[ ! -d "${CLAUDE_CODE_ACTION_ROOT}" ]]; then
echo "::error::claude-code-action not found at expected location: ${CLAUDE_CODE_ACTION_ROOT}"
exit 1
else
claude_dir="$(find "${CLAUDE_CODE_ACTION_ROOT}" -mindepth 2 -maxdepth 2 -type d -name .claude -print -quit)"
if [[ -z "${claude_dir}" ]]; then
echo "::error::Could not find .claude under ${CLAUDE_CODE_ACTION_ROOT}"
exit 1
else
install -d "${HOME}/.claude/agents" "${HOME}/.claude/commands"
rsync -av "${claude_dir}/agents/" "${HOME}/.claude/agents/"
rsync -av "${claude_dir}/commands/" "${HOME}/.claude/commands/"
fi
fi
- name: Run Claude Code
uses: anthropics/claude-code-action@0d2971c794049856e777f4e8bb5a81623ec632d3 # v1.0.100
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} # zizmor: ignore[secrets-outside-env] caller-provided secret
# Allow Claude to read CI results on PRs.
additional_permissions: |
actions: read
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'
# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'
claude_args: ${{ inputs.claude-args }}