wip bug squashing #6
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
| name: Claude Comment Response | ||
| on: | ||
| issue_comment: | ||
| types: [created] # Triggers when someone comments on an issue or PR | ||
| jobs: | ||
| respond-to-claude-mention: | ||
| # Only run if the comment mentions @claude | ||
| if: contains(github.event.comment.body, '@claude') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
| discussions: write | ||
| id-token: write | ||
| statuses: write | ||
| workflow: write | ||
| actions: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Fetch full history for accurate diffs | ||
| # If running on a PR comment, we need to explicitly check out the PR branch | ||
| - name: Checkout PR branch if needed | ||
| if: github.event.issue.pull_request | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Get the PR number from the issue object | ||
| PR_NUMBER="${{ github.event.issue.number }}" | ||
| echo "Checking out PR #${PR_NUMBER}" | ||
| # Get PR info | ||
| PR_INFO=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") | ||
| # Extract the PR branch ref and other details | ||
| PR_BRANCH=$(echo "$PR_INFO" | jq -r .head.ref) | ||
| PR_SHA=$(echo "$PR_INFO" | jq -r .head.sha) | ||
| PR_REPO=$(echo "$PR_INFO" | jq -r .head.repo.full_name) | ||
| echo "PR branch is $PR_BRANCH from repo $PR_REPO with commit SHA $PR_SHA" | ||
| # Fetch the PR as a local branch (works for forks too) | ||
| git fetch origin "pull/$PR_NUMBER/head:pr-$PR_NUMBER" | ||
| git checkout "pr-$PR_NUMBER" | ||
| # Verify checkout | ||
| echo "Current branch details:" | ||
| git status | ||
| git rev-parse HEAD | ||
| - name: Claude Response | ||
| uses: anthropics/claude-code-action@beta | ||
| with: | ||
| # Your GitHub token for API operations | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| # Pass the comment text as the prompt | ||
| direct_prompt: "${{ github.event.comment.body }}" | ||
| # Define which tools Claude can use | ||
| allowed_tools: |- | ||
| # Git inspection commands (read-only) | ||
| Bash(git status) | ||
| Bash(git log) | ||
| Bash(git show) | ||
| Bash(git blame) | ||
| Bash(git ls-files) | ||
| Bash(git branch) | ||
| Bash(git tag) | ||
| Bash(git diff) | ||
| # File modifications | ||
| Bash(git add) | ||
| Bash(git commit) | ||
| # File exploration tools | ||
| View # Read file contents | ||
| Edit # Edit files | ||
| GlobTool # Find files by pattern | ||
| GrepTool # Search file contents | ||
| BatchTool # Run multiple tools in parallel | ||
| # Timeout after 20 minutes | ||
| timeout_minutes: 20 | ||
| # Your Anthropic API key (stored as a GitHub secret) | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||