|
| 1 | +name: Claude PR Assistant |
| 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 | +on: |
| 6 | + issue_comment: |
| 7 | + types: [created] |
| 8 | + pull_request_review_comment: |
| 9 | + types: [created] |
| 10 | + pull_request_review: |
| 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 | + |
| 23 | +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 | + |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + # Set timeout to prevent runaway workflows |
| 31 | + timeout-minutes: 20 |
| 32 | + |
| 33 | + steps: |
| 34 | + # Check out the repository code so Claude can access it |
| 35 | + - name: Checkout repository |
| 36 | + uses: actions/checkout@v4 |
| 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 |
| 42 | + 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 }} |
| 47 | + |
| 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 }} |
0 commit comments