|
| 1 | +name: Claude Fix Issue |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + pull-requests: write |
| 10 | + issues: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + authorize: |
| 15 | + if: >- |
| 16 | + !github.event.issue.pull_request && |
| 17 | + contains(github.event.comment.body, '/claude fix') |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Check team membership |
| 21 | + uses: actions/github-script@v7 |
| 22 | + with: |
| 23 | + github-token: ${{ secrets.ORG_TEAM_READ_TOKEN }} |
| 24 | + script: | |
| 25 | + const username = context.payload.comment.user.login; |
| 26 | + try { |
| 27 | + const res = await github.rest.teams.getMembershipForUserInOrg({ |
| 28 | + org: 'NVIDIA-NeMo', |
| 29 | + team_slug: 'speech_team', |
| 30 | + username, |
| 31 | + }); |
| 32 | + if (res.data.state !== 'active') { |
| 33 | + core.setFailed(`${username} is not an active member of NVIDIA Speech Team`); |
| 34 | + } |
| 35 | + } catch (e) { |
| 36 | + core.setFailed(`${username} is not a member of NVIDIA Speech Team`); |
| 37 | + } |
| 38 | +
|
| 39 | + acknowledge: |
| 40 | + needs: authorize |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Add eyes reaction to comment |
| 44 | + uses: actions/github-script@v7 |
| 45 | + with: |
| 46 | + script: | |
| 47 | + await github.rest.reactions.createForIssueComment({ |
| 48 | + owner: context.repo.owner, |
| 49 | + repo: context.repo.repo, |
| 50 | + comment_id: context.payload.comment.id, |
| 51 | + content: 'eyes' |
| 52 | + }); |
| 53 | +
|
| 54 | + claude-fix: |
| 55 | + needs: acknowledge |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + - uses: anthropics/claude-code-action@v1 |
| 60 | + id: claude |
| 61 | + with: |
| 62 | + prompt: | |
| 63 | + You are a developer working on the NeMo repository. |
| 64 | + Implement a focused fix for the issue based on the issue description and comments. |
| 65 | +
|
| 66 | + Requirements: |
| 67 | + - Always use `git commit -s` to sign off all commits (DCO requirement). |
| 68 | + - Prioritize correctness and minimal scope; avoid unrelated refactors. |
| 69 | + - Reproduce or reason about the failure first, then implement the smallest robust fix. |
| 70 | + - If required, add or update tests for the changed behavior. If tests are not feasible, explain why. |
| 71 | + - If required, update related docs or comments when behavior or usage changes. |
| 72 | +
|
| 73 | + PR expectations: |
| 74 | + - Create a new branch and open a pull request with your changes. |
| 75 | + - Include a concise summary of root cause and fix based on the following PR template: |
| 76 | + ``` |
| 77 | + # What does this PR do ? |
| 78 | + Add a one line overview of what this PR aims to accomplish. |
| 79 | +
|
| 80 | + # Changelog |
| 81 | + Add specific line by line info of high level changes in this PR. |
| 82 | +
|
| 83 | + # Usage |
| 84 | + Add a usage example of the changed functionality. |
| 85 | + |
| 86 | + Related to #${{ github.event.issue.number }} |
| 87 | +
|
| 88 | + This PR is created by Claude. |
| 89 | + ``` |
| 90 | +
|
| 91 | + |
| 92 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 93 | + |
| 94 | + - name: Label PR with agent-contribution |
| 95 | + if: steps.claude.outputs.branch_name |
| 96 | + uses: actions/github-script@v7 |
| 97 | + with: |
| 98 | + script: | |
| 99 | + const prs = await github.rest.pulls.list({ |
| 100 | + owner: context.repo.owner, |
| 101 | + repo: context.repo.repo, |
| 102 | + head: `${context.repo.owner}:${process.env.BRANCH_NAME}`, |
| 103 | + state: 'open' |
| 104 | + }); |
| 105 | + if (prs.data.length > 0) { |
| 106 | + await github.rest.issues.addLabels({ |
| 107 | + owner: context.repo.owner, |
| 108 | + repo: context.repo.repo, |
| 109 | + issue_number: prs.data[0].number, |
| 110 | + labels: ['agent-contribution'] |
| 111 | + }); |
| 112 | + } |
| 113 | + env: |
| 114 | + BRANCH_NAME: ${{ steps.claude.outputs.branch_name }} |
0 commit comments