Skip to content

Commit 9d834a5

Browse files
Add Claude GitHub Actions workflows (#1288)
## Summary - Add `claude.yml` for `@claude` mentions on issues and PRs - Add `claude-code-review.yml` for on-demand `/review` PR reviews - Matches the workflow setup in `databricks-odbc` - Uses `databricks-protected-runner-group` runner NO_CHANGELOG=true This pull request was AI-assisted by Isaac. --------- Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com> Co-authored-by: Samikshya Chand <148681192+samikshya-db@users.noreply.github.com>
1 parent 561d89d commit 9d834a5

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Claude Code Review
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
claude-review:
9+
if: |
10+
github.event.issue.pull_request &&
11+
contains(github.event.comment.body, '/review') &&
12+
(github.event.comment.author_association == 'OWNER' ||
13+
github.event.comment.author_association == 'MEMBER' ||
14+
github.event.comment.author_association == 'COLLABORATOR')
15+
runs-on:
16+
group: databricks-protected-runner-group
17+
labels: [linux-ubuntu-latest]
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
issues: write
22+
id-token: write
23+
24+
steps:
25+
- name: React to comment
26+
run: |
27+
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
28+
-f content=eyes
29+
env:
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Get PR head ref
33+
id: pr
34+
run: |
35+
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
36+
echo "ref=$(echo "$PR_DATA" | jq -r .head.ref)" >> "$GITHUB_OUTPUT"
37+
echo "number=$(echo "$PR_DATA" | jq -r .number)" >> "$GITHUB_OUTPUT"
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
with:
44+
ref: ${{ steps.pr.outputs.ref }}
45+
fetch-depth: 0
46+
47+
- name: Run Claude Code Review
48+
id: claude-review
49+
uses: anthropics/claude-code-action@v1
50+
with:
51+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
52+
review_comment_id: ${{ github.event.comment.id }}
53+
trigger_phrase: "/review"
54+
timeout_minutes: 15

.github/workflows/claude.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
23+
(github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'COLLABORATOR'))
24+
runs-on:
25+
group: databricks-protected-runner-group
26+
labels: [linux-ubuntu-latest]
27+
permissions:
28+
contents: read
29+
pull-requests: read
30+
issues: read
31+
id-token: write
32+
actions: read # Required for Claude to read CI results on PRs
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 1
38+
39+
- name: Run Claude Code
40+
id: claude
41+
uses: anthropics/claude-code-action@v1
42+
with:
43+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
44+
45+
# This is an optional setting that allows Claude to read CI results on PRs
46+
additional_permissions: |
47+
actions: read
48+
49+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
50+
# prompt: 'Update the pull request description to include a summary of changes.'
51+
52+
# Optional: Add claude_args to customize behavior and configuration
53+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
54+
# or https://code.claude.com/docs/en/cli-reference for available options
55+
# claude_args: '--allowed-tools Bash(gh pr:*)'
56+

0 commit comments

Comments
 (0)