Skip to content

Commit d03e86e

Browse files
iaminaweclaude
andauthored
Add Claude GitHub Actions integration (#9)
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * chore: remove automatic PR review workflow Remove automatic Claude PR review workflow as repository already has a PR reviewer in place. Keep the @claude mention workflow (claude.yml) for on-demand assistance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: add newline at end of claude.yml Fix linting error by ensuring file ends with a newline. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: trigger on issue edited instead of assigned Change Claude workflow to trigger on issue edit events instead of assignment events for better workflow integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * feat: add timeout and concurrency controls to Claude workflow Add safeguards to prevent runaway or duplicate jobs: - Set 10 minute timeout for job execution - Configure concurrency grouping by event type and issue/PR number - Enable cancel-in-progress to stop duplicate runs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * feat: restrict Claude workflow to authorized users only Add author association checks to ensure only repository owners, members, and collaborators can trigger the Claude workflow. This prevents unauthorized users from triggering potentially expensive or sensitive operations. Changes: - Check author_association for all event types - Require OWNER, MEMBER, or COLLABORATOR status - Add null checks for review and issue bodies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * security: pin claude-code-action to specific commit SHA Pin action to verified commit SHA instead of mutable tag for supply chain security. This prevents potential attacks where a tag could be moved to malicious code. - Pin to e8bad572273ce919ba15fec95aef0ce974464753 (v1 release) - Add inline comment for version reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: simplify author association checks Replace verbose OR chains with concise contains() + fromJson() pattern for checking author associations. This improves readability and maintainability. Before: Multiple OR conditions for each event type After: contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), author_association) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent 24083cf commit d03e86e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/claude.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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, edited]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
timeout-minutes: 10
16+
concurrency:
17+
group: claude-${{ github.event_name }}-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
18+
cancel-in-progress: true
19+
if: |
20+
(
21+
github.event_name == 'issue_comment' &&
22+
contains(github.event.comment.body, '@claude') &&
23+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
24+
) || (
25+
github.event_name == 'pull_request_review_comment' &&
26+
contains(github.event.comment.body, '@claude') &&
27+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
28+
) || (
29+
github.event_name == 'pull_request_review' &&
30+
github.event.review.body != null &&
31+
contains(github.event.review.body, '@claude') &&
32+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)
33+
) || (
34+
github.event_name == 'issues' &&
35+
(
36+
(github.event.issue.body != null && contains(github.event.issue.body, '@claude')) ||
37+
contains(github.event.issue.title, '@claude')
38+
) &&
39+
contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
40+
)
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
pull-requests: read
45+
issues: read
46+
id-token: write
47+
actions: read # Required for Claude to read CI results on PRs
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 1
53+
54+
- name: Run Claude Code
55+
id: claude
56+
uses: anthropics/claude-code-action@e8bad572273ce919ba15fec95aef0ce974464753 # v1
57+
with:
58+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
59+
60+
# This is an optional setting that allows Claude to read CI results on PRs
61+
additional_permissions: |
62+
actions: read
63+
64+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
65+
# prompt: 'Update the pull request description to include a summary of changes.'
66+
67+
# Optional: Add claude_args to customize behavior and configuration
68+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
69+
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
70+
# claude_args: '--allowed-tools Bash(gh pr:*)'

0 commit comments

Comments
 (0)