Skip to content

Commit c46e877

Browse files
Add Claude Code workflow for AI-assisted PR reviews
Add a GitHub Actions workflow that provides AI-assisted PR reviews and interactive @claude mentions using Claude Code backed by Databricks Model Serving. The workflow dispatches to eng-dev-ecosystem's protected runners (whose IPs are allowlisted by the Databricks account IP ACL) via the DECO workflow trigger GitHub App. Two modes: - Review: automatic on PR open, posts a review comment - Assist: triggered by @claude mentions, can edit code and push Access is restricted to COLLABORATOR/MEMBER/OWNER via author_association allowlists. Co-authored-by: Isaac
1 parent 3f3cc2b commit c46e877

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

.github/workflows/claude-code.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Claude Code
2+
3+
# AI-assisted PR reviews and interactive @claude mentions.
4+
#
5+
# The actual Claude Code execution runs in eng-dev-ecosystem on
6+
# protected runners whose IPs are allowlisted by the Databricks
7+
# account IP ACL. This workflow is a thin trigger that dispatches
8+
# to eng-dev-ecosystem via the DECO workflow trigger GitHub App.
9+
10+
on:
11+
# Triggers automatic review when a PR is first opened.
12+
pull_request:
13+
types: [opened]
14+
15+
# Enables @claude mentions in PR conversation comments.
16+
# (GitHub fires issue_comment for top-level PR comments.)
17+
issue_comment:
18+
types: [created]
19+
20+
# Enables @claude mentions in inline review comments.
21+
pull_request_review_comment:
22+
types: [created]
23+
24+
jobs:
25+
# Automatic review on PR open. For re-reviews, comment "@claude review".
26+
# Restrict to org members/owners to prevent untrusted users (e.g. external
27+
# fork PRs) from consuming model serving resources. See:
28+
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
29+
review:
30+
if: |
31+
github.event_name == 'pull_request' &&
32+
contains(fromJson('["MEMBER","OWNER"]'), github.event.pull_request.author_association)
33+
concurrency:
34+
group: claude-review-${{ github.event.pull_request.number }}
35+
cancel-in-progress: true
36+
runs-on:
37+
group: databricks-deco-testing-runner-group
38+
labels: ubuntu-latest-deco
39+
environment: test-trigger-is
40+
permissions:
41+
contents: read
42+
43+
steps:
44+
- name: Generate GitHub App token
45+
id: token
46+
uses: actions/create-github-app-token@v2
47+
with:
48+
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
49+
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
50+
owner: databricks-eng
51+
repositories: eng-dev-ecosystem
52+
53+
- name: Trigger Claude Code review
54+
run: |
55+
gh workflow run cli-claude-code.yml \
56+
-R databricks-eng/eng-dev-ecosystem \
57+
--ref main \
58+
-F pull_request_number=${{ github.event.pull_request.number }} \
59+
-F event_type=review
60+
env:
61+
GH_TOKEN: ${{ steps.token.outputs.token }}
62+
63+
# Interactive @claude mentions (PRs only, trusted authors only).
64+
# Restrict to org members/owners to prevent untrusted users from triggering
65+
# Claude with write access to the repo. See:
66+
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
67+
assist:
68+
if: |
69+
github.event.comment.user.type != 'Bot' &&
70+
contains(fromJson('["MEMBER","OWNER"]'), github.event.comment.author_association) &&
71+
(
72+
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) ||
73+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude'))
74+
)
75+
runs-on:
76+
group: databricks-deco-testing-runner-group
77+
labels: ubuntu-latest-deco
78+
environment: test-trigger-is
79+
permissions:
80+
contents: read
81+
82+
steps:
83+
- name: Generate GitHub App token
84+
id: token
85+
uses: actions/create-github-app-token@v2
86+
with:
87+
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
88+
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
89+
owner: databricks-eng
90+
repositories: eng-dev-ecosystem
91+
92+
- name: Determine PR number
93+
id: pr
94+
run: |
95+
if [ -n "$ISSUE_NUMBER" ]; then
96+
echo "number=$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"
97+
else
98+
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
99+
fi
100+
env:
101+
ISSUE_NUMBER: ${{ github.event.issue.number }}
102+
PR_NUMBER: ${{ github.event.pull_request.number }}
103+
104+
- name: Trigger Claude Code assist
105+
uses: actions/github-script@v7
106+
with:
107+
github-token: ${{ steps.token.outputs.token }}
108+
script: |
109+
await github.rest.actions.createWorkflowDispatch({
110+
owner: 'databricks-eng',
111+
repo: 'eng-dev-ecosystem',
112+
workflow_id: 'cli-claude-code.yml',
113+
ref: 'main',
114+
inputs: {
115+
pull_request_number: '${{ steps.pr.outputs.number }}',
116+
event_type: 'assist',
117+
comment_body: process.env.COMMENT_BODY
118+
}
119+
});
120+
env:
121+
COMMENT_BODY: ${{ github.event.comment.body }}

0 commit comments

Comments
 (0)