-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (130 loc) · 6.8 KB
/
claude-pr-assistant.yml
File metadata and controls
137 lines (130 loc) · 6.8 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Claude PR Assistant
on:
workflow_run:
workflows: ['Pull Request Checks']
types: [completed]
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
pull_request_review:
types: [submitted, edited]
permissions:
contents: read
jobs:
resolve-pr:
permissions:
contents: read
pull-requests: read
if: >-
github.repository_owner == 'viamrobotics' &&
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'claude/')
runs-on: ubuntu-latest
outputs:
pr_found: ${{ steps.pr.outputs.found }}
pr_number: ${{ steps.pr.outputs.number }}
pr_title: ${{ steps.pr.outputs.title }}
branch: ${{ steps.pr.outputs.branch }}
steps:
- name: Find PR for branch
id: pr
# actions/github-script@v8.0.0
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
with:
script: |
const branch = context.payload.workflow_run.head_branch;
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${branch}`,
state: 'open'
});
if (pulls.length === 0) {
core.info('No open PR found for branch ' + branch);
core.setOutput('found', 'false');
return;
}
const pr = pulls[0];
core.setOutput('found', 'true');
core.setOutput('number', String(pr.number));
core.setOutput('title', pr.title);
core.setOutput('branch', branch);
auto-review:
needs: resolve-pr
if: needs.resolve-pr.outputs.pr_found == 'true'
permissions:
contents: write
pull-requests: write
actions: read
issues: write
id-token: write
# viamrobotics/claude-ci-workflows@v1.17.3
uses: viamrobotics/claude-ci-workflows/.github/workflows/claude-auto-review.yml@3ad96b0ccbb5ee0d7e2cde98653fae0c453e68bb
with:
pr_number: ${{ needs.resolve-pr.outputs.pr_number }}
pr_title: ${{ needs.resolve-pr.outputs.pr_title }}
branch: ${{ needs.resolve-pr.outputs.branch }}
install_command: |
NODE22_BIN=$(ls -d /opt/hostedtoolcache/node/22.*/x64/bin | tail -1)
echo "$NODE22_BIN" >> "$GITHUB_PATH"
export PATH="$NODE22_BIN:$PATH"
corepack enable
pnpm install
max_turns: 50
allowed_tools: 'Edit,Read,Write,Glob,Grep,mcp__github_inline_comment__create_inline_comment,Bash(pnpm *),Bash(npx *),Bash(node *),Bash(ls *),Bash(find *),Bash(git config *),Bash(git add *),Bash(git commit *),Bash(git push *),Bash(git status*),Bash(git diff*),Bash(git log*),Bash(git checkout *),Bash(git branch *),Bash(git rev-parse *),Bash(git fetch *),Bash(gh pr review*),Bash(gh pr comment*),Bash(gh pr diff*),Bash(gh pr view*)'
extra_review_instructions: |
- Do NOT manually edit `dist/**` (generated) or `pnpm-lock.yaml` (regenerated by pnpm).
- If you fix issues, only run verification commands relevant to the files you changed:
- Svelte / TS / JS files (.svelte, .ts, .js): `pnpm lint`, `pnpm check`, and `pnpm test`
- Do NOT run unrelated commands, they waste turns and time.
- This repo uses Svelte 5 runes and SvelteKit. Consult the Svelte MCP server when reviewing `.svelte` / `.svelte.ts` / `.svelte.js` files.
- NEVER use curl, python3, or WebFetch to submit GitHub reviews. Use ONLY `gh pr review` and `gh pr comment`.
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
SLACK_AI_WORKFLOW_ALERT_WEBHOOK_URL: ${{ secrets.SLACK_AI_WORKFLOW_ALERT_WEBHOOK_URL }}
on-demand:
permissions:
contents: write
pull-requests: write
actions: read
issues: write
id-token: write
if: >-
github.repository_owner == 'viamrobotics' &&
(
(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 == 'pull_request_review' && github.event.review.state != 'approved' && github.event.review.user.type != 'Bot' && startsWith(github.event.pull_request.head.ref, 'claude/'))
)
# viamrobotics/claude-ci-workflows@v1.17.3
uses: viamrobotics/claude-ci-workflows/.github/workflows/claude-pr-assistant.yml@3ad96b0ccbb5ee0d7e2cde98653fae0c453e68bb
with:
install_command: |
NODE22_BIN=$(ls -d /opt/hostedtoolcache/node/22.*/x64/bin | tail -1)
echo "$NODE22_BIN" >> "$GITHUB_PATH"
export PATH="$NODE22_BIN:$PATH"
corepack enable
pnpm install
max_turns: 50
allowed_tools: 'Edit,Read,Write,Glob,Grep,mcp__github_inline_comment__create_inline_comment,Bash(pnpm *),Bash(npx *),Bash(node *),Bash(ls *),Bash(find *),Bash(git config *),Bash(git add *),Bash(git commit *),Bash(git push *),Bash(git status*),Bash(git diff*),Bash(git log*),Bash(git checkout *),Bash(git branch *),Bash(git rev-parse *),Bash(git fetch *),Bash(gh pr review*),Bash(gh pr comment*),Bash(gh pr view*),Bash(gh pr diff*)'
extra_review_instructions: |
- Do NOT manually edit `dist/**` (generated) or `pnpm-lock.yaml` (regenerated by pnpm).
- Only run verification commands relevant to the files you changed:
- Svelte / TS / JS files (.svelte, .ts, .js): `pnpm lint`, `pnpm check`, and `pnpm test`
- Do NOT run unrelated commands, they waste turns and time.
- If a lint or test command fails more than twice on the same issue, commit what you have, push, and note the unresolved issue in a PR comment.
- Before editing code, read 1-2 similar functions or components in the same file or package to follow existing patterns and conventions.
- This repo uses Svelte 5 runes and SvelteKit. Consult the Svelte MCP server when editing or reviewing `.svelte` / `.svelte.ts` / `.svelte.js` files.
- NEVER use curl, python3, or WebFetch to submit GitHub reviews. Use ONLY `gh pr review` and `gh pr comment`.
extra_system_prompt: >-
This is a Svelte 5 + SvelteKit TypeScript library (`@viamrobotics/test-widgets`).
It is verifiable with `pnpm lint`, `pnpm check`, `pnpm test`, and `pnpm build`.
Do NOT modify `dist/**` (generated), `.changeset/**` (versioning), or `pnpm-lock.yaml` (regenerated by pnpm).
Package manager: pnpm. Node: 22.22.1.
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}