changed license #26
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 PR Assistant | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_review_comment: | |
| types: [created] | |
| issues: | |
| types: [opened, assigned] | |
| pull_request_review: | |
| types: [submitted] | |
| jobs: | |
| claude-code-action: | |
| if: | | |
| (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | |
| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | |
| (github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| id-token: write | |
| steps: | |
| - name: Get branch reference | |
| id: get-branch | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let ref = 'main'; // default fallback | |
| // For PR-related events | |
| if (context.eventName === 'pull_request_review_comment' || context.eventName === 'pull_request_review') { | |
| ref = context.payload.pull_request.head.ref; | |
| } | |
| // For issue comments on PRs | |
| else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) { | |
| const pr_number = context.payload.issue.number; | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: pr_number | |
| }); | |
| ref = pr.head.ref; | |
| } | |
| // For issues (including issue comments on regular issues) | |
| else if (context.eventName === 'issues' || (context.eventName === 'issue_comment' && !context.payload.issue.pull_request)) { | |
| const issue_number = context.payload.issue.number; | |
| // Get linked branches via GraphQL API | |
| const query = ` | |
| query($owner: String!, $repo: String!, $issue: Int!) { | |
| repository(owner: $owner, name: $repo) { | |
| issue(number: $issue) { | |
| linkedBranches(first: 10) { | |
| nodes { | |
| ref { | |
| name | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| `; | |
| try { | |
| const result = await github.graphql(query, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue: issue_number | |
| }); | |
| // Use the first linked branch if available | |
| if (result.repository.issue.linkedBranches.nodes.length > 0) { | |
| ref = result.repository.issue.linkedBranches.nodes[0].ref.name; | |
| console.log(`Using linked branch: ${ref}`); | |
| } else { | |
| console.log('No linked branch found, using main'); | |
| } | |
| } catch (error) { | |
| console.log('Error fetching linked branches, using main:', error); | |
| } | |
| } | |
| core.setOutput('ref', ref); | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ steps.get-branch.outputs.ref }} | |
| - name: Run Claude PR Action | |
| uses: anthropics/claude-code-action@beta | |
| with: | |
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | |
| timeout_minutes: "60" | |
| model: "claude-opus-4-20250514" |