|
| 1 | +name: Auto Request Reviewers |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, ready_for_review, synchronize] |
| 5 | + |
| 6 | +jobs: |
| 7 | + add-reviews: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + permissions: |
| 10 | + pull-requests: write |
| 11 | + contents: read |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Request review from GitHub Copilot |
| 17 | + uses: actions/github-script@v7 |
| 18 | + with: |
| 19 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + script: | |
| 21 | + try { |
| 22 | + // Request GitHub Copilot review |
| 23 | + await github.rest.pulls.createReview({ |
| 24 | + owner: context.repo.owner, |
| 25 | + repo: context.repo.repo, |
| 26 | + pull_number: context.issue.number, |
| 27 | + body: '@github-copilot review this PR', |
| 28 | + event: 'COMMENT' |
| 29 | + }); |
| 30 | +
|
| 31 | + console.log('Successfully requested GitHub Copilot review'); |
| 32 | + } catch (error) { |
| 33 | + console.log('Error requesting Copilot review:', error.message); |
| 34 | +
|
| 35 | + // Fallback: Add a comment to trigger Copilot |
| 36 | + try { |
| 37 | + await github.rest.issues.createComment({ |
| 38 | + owner: context.repo.owner, |
| 39 | + repo: context.repo.repo, |
| 40 | + issue_number: context.issue.number, |
| 41 | + body: '@github-copilot review' |
| 42 | + }); |
| 43 | + console.log('Added fallback comment to trigger Copilot review'); |
| 44 | + } catch (commentError) { |
| 45 | + console.log('Error adding comment:', commentError.message); |
| 46 | + } |
| 47 | + } |
0 commit comments