|
1 | 1 | name: Claude PR Assistant |
2 | 2 |
|
3 | | -# This workflow allows mentioning @claude in issues and PRs for interactive AI assistance |
4 | | -# Trigger conditions: issue comments, PR review comments, PR reviews, and new issues |
5 | 3 | on: |
6 | 4 | issue_comment: |
7 | 5 | types: [created] |
8 | 6 | pull_request_review_comment: |
9 | 7 | types: [created] |
| 8 | + issues: |
| 9 | + types: [opened, assigned] |
10 | 10 | pull_request_review: |
11 | 11 | types: [submitted] |
12 | | - issues: |
13 | | - types: [opened, edited] |
14 | | - |
15 | | -# Permissions required for Claude to read repository content and interact with PRs/issues |
16 | | -permissions: |
17 | | - contents: read # Read repository files and code |
18 | | - pull-requests: read # Read PR information and comments |
19 | | - issues: read # Read issue information and comments |
20 | | - actions: read # Read workflow information |
21 | | - id-token: write # Required for authentication with Anthropic |
22 | 12 |
|
23 | 13 | jobs: |
24 | | - claude-assistant: |
25 | | - # Only run if the comment/issue contains @claude mention |
26 | | - if: contains(github.event.comment.body, '@claude') || contains(github.event.issue.body, '@claude') || contains(github.event.review.body, '@claude') |
27 | | - |
| 14 | + claude: |
| 15 | + name: Claude Code Action |
| 16 | + if: | |
| 17 | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || |
| 18 | + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || |
| 19 | + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || |
| 20 | + (github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) |
28 | 21 | runs-on: ubuntu-latest |
29 | | - |
30 | | - # Set timeout to prevent runaway workflows |
31 | 22 | timeout-minutes: 20 |
32 | | - |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + pull-requests: read |
| 26 | + issues: read |
| 27 | + id-token: write |
| 28 | + actions: read # Required for Claude to read CI results on PRs |
33 | 29 | steps: |
34 | | - # Check out the repository code so Claude can access it |
35 | 30 | - name: Checkout repository |
36 | | - uses: actions/checkout@v5 |
37 | | - |
38 | | - # Run Claude Code Action to provide AI assistance |
39 | | - # This action will analyze the context and respond to the @claude mention |
40 | | - - name: Run Claude PR Assistant |
41 | | - uses: anthropics/claude-code-action@v1 |
| 31 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
42 | 32 | with: |
43 | | - # API key for authenticating with Anthropic's Claude API |
44 | | - # This must be added as a repository secret at: |
45 | | - # Settings → Secrets and variables → Actions → New repository secret |
46 | | - anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 33 | + fetch-depth: 1 |
47 | 34 |
|
48 | | - # GitHub token is automatically provided by GitHub Actions |
49 | | - # Used for reading/writing comments and accessing repository data |
50 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + - name: Run Claude Code |
| 36 | + id: claude |
| 37 | + uses: anthropics/claude-code-action@f4d737af0b61a79741d8246c5207da5887746212 # v1 |
| 38 | + with: |
| 39 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
0 commit comments