duplicate-prs.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. name: Duplicate PR Check
  2. on:
  3. pull_request_target:
  4. types: [opened]
  5. jobs:
  6. check-duplicates:
  7. if: |
  8. github.event.pull_request.user.login != 'actions-user' &&
  9. github.event.pull_request.user.login != 'opencode' &&
  10. github.event.pull_request.user.login != 'rekram1-node' &&
  11. github.event.pull_request.user.login != 'thdxr' &&
  12. github.event.pull_request.user.login != 'kommander' &&
  13. github.event.pull_request.user.login != 'jayair' &&
  14. github.event.pull_request.user.login != 'fwang' &&
  15. github.event.pull_request.user.login != 'adamdotdevin' &&
  16. github.event.pull_request.user.login != 'iamdavidhill' &&
  17. github.event.pull_request.user.login != 'opencode-agent[bot]'
  18. runs-on: blacksmith-4vcpu-ubuntu-2404
  19. permissions:
  20. contents: read
  21. pull-requests: write
  22. steps:
  23. - name: Checkout repository
  24. uses: actions/checkout@v4
  25. with:
  26. fetch-depth: 1
  27. - name: Setup Bun
  28. uses: ./.github/actions/setup-bun
  29. - name: Install dependencies
  30. run: bun install
  31. - name: Install opencode
  32. run: curl -fsSL https://opencode.ai/install | bash
  33. - name: Build prompt
  34. env:
  35. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  36. PR_NUMBER: ${{ github.event.pull_request.number }}
  37. run: |
  38. {
  39. echo "Check for duplicate PRs related to this new PR:"
  40. echo ""
  41. echo "CURRENT_PR_NUMBER: $PR_NUMBER"
  42. echo ""
  43. echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)"
  44. echo ""
  45. echo "Description:"
  46. gh pr view "$PR_NUMBER" --json body --jq .body
  47. } > pr_info.txt
  48. - name: Check for duplicate PRs
  49. env:
  50. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. PR_NUMBER: ${{ github.event.pull_request.number }}
  53. run: |
  54. COMMENT=$(bun script/duplicate-pr.ts -f pr_info.txt "Check the attached file for PR details and search for duplicates")
  55. gh pr comment "$PR_NUMBER" --body "_The following comment was made by an LLM, it may be inaccurate:_
  56. $COMMENT"