pr-management.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. name: pr-management
  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. if [ "$COMMENT" != "No duplicate PRs found" ]; then
  56. gh pr comment "$PR_NUMBER" --body "_The following comment was made by an LLM, it may be inaccurate:_
  57. $COMMENT"
  58. fi
  59. add-contributor-label:
  60. runs-on: ubuntu-latest
  61. permissions:
  62. pull-requests: write
  63. issues: write
  64. steps:
  65. - name: Add Contributor Label
  66. uses: actions/github-script@v8
  67. with:
  68. script: |
  69. const isPR = !!context.payload.pull_request;
  70. const issueNumber = isPR ? context.payload.pull_request.number : context.payload.issue.number;
  71. const authorAssociation = isPR ? context.payload.pull_request.author_association : context.payload.issue.author_association;
  72. if (authorAssociation === 'CONTRIBUTOR') {
  73. await github.rest.issues.addLabels({
  74. owner: context.repo.owner,
  75. repo: context.repo.repo,
  76. issue_number: issueNumber,
  77. labels: ['contributor']
  78. });
  79. }