Claude Code #2060
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Claude Code Integration | |
# | |
# Allows organization members to invoke Claude AI assistant by mentioning @claude | |
# in GitHub issues, comments, and pull request reviews. | |
# | |
# Restricted to trusted users only. | |
name: Claude Code | |
# Trigger on various GitHub events where users might mention @claude | |
on: | |
issue_comment: | |
types: [created] | |
pull_request_review_comment: | |
types: [created] | |
pull_request_review: | |
types: [submitted] | |
issues: | |
types: [opened, assigned] | |
jobs: | |
claude: | |
# Only run if @claude is mentioned AND user has appropriate repository permissions | |
# | |
# Checks each event type: | |
# - issue_comment | |
# - pull_request_review_comment | |
# - pull_request_review | |
# - issues | |
if: | | |
(github.event_name == 'issue_comment' && | |
contains(github.event.comment.body, '@claude') && | |
contains('MEMBER OWNER COLLABORATOR', github.event.comment.author_association)) || | |
(github.event_name == 'pull_request_review_comment' && | |
contains(github.event.comment.body, '@claude') && | |
contains('MEMBER OWNER COLLABORATOR', github.event.comment.author_association)) || | |
(github.event_name == 'pull_request_review' && | |
contains(github.event.review.body, '@claude') && | |
contains('MEMBER OWNER COLLABORATOR', github.event.review.author_association)) || | |
(github.event_name == 'issues' && | |
(contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) && | |
contains('MEMBER OWNER COLLABORATOR', github.event.issue.user.author_association)) | |
runs-on: ubuntu-latest | |
# Permissions for Claude to read repository context and comment on PRs/issues | |
permissions: | |
contents: read # Read repository files | |
pull-requests: write # Comment on PRs | |
issues: write # Comment on issues | |
id-token: write # Generate OIDC token for secure authentication | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 1 | |
- name: Run Claude Code | |
id: claude | |
uses: anthropics/claude-code-action@beta | |
with: | |
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | |
max_turns: "10" | |
timeout_minutes: "5" | |