duplicate-prs.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 opencode
  30. run: curl -fsSL https://opencode.ai/install | bash
  31. - name: Build prompt
  32. env:
  33. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  34. PR_NUMBER: ${{ github.event.pull_request.number }}
  35. run: |
  36. {
  37. echo "Check for duplicate PRs related to this new PR:"
  38. echo ""
  39. echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)"
  40. echo ""
  41. echo "Description:"
  42. gh pr view "$PR_NUMBER" --json body --jq .body
  43. } > pr_info.txt
  44. - name: Check for duplicate PRs
  45. env:
  46. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  47. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  48. PR_NUMBER: ${{ github.event.pull_request.number }}
  49. run: |
  50. COMMENT=$(opencode run --agent duplicate-pr --print -f pr_info.txt "Check the attached file for PR details and search for duplicates")
  51. gh pr comment "$PR_NUMBER" --body "_The following comment was made by an LLM, it may be inaccurate:_
  52. $COMMENT"