|
5 | 5 | types: [opened] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - check-duplicates: |
9 | | - runs-on: blacksmith-4vcpu-ubuntu-2404 |
10 | | - permissions: |
11 | | - contents: read |
12 | | - pull-requests: write |
13 | | - steps: |
14 | | - - name: Checkout repository |
15 | | - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
16 | | - with: |
17 | | - fetch-depth: 1 |
18 | | - |
19 | | - - name: Check team membership |
20 | | - id: team-check |
21 | | - run: | |
22 | | - LOGIN="${{ github.event.pull_request.user.login }}" |
23 | | - if [ "$LOGIN" = "opencode-agent[bot]" ] || grep -qxF "$LOGIN" .github/TEAM_MEMBERS; then |
24 | | - echo "is_team=true" >> "$GITHUB_OUTPUT" |
25 | | - echo "Skipping: $LOGIN is a team member or bot" |
26 | | - else |
27 | | - echo "is_team=false" >> "$GITHUB_OUTPUT" |
28 | | - fi |
29 | | -
|
30 | | - - name: Setup Bun |
31 | | - if: steps.team-check.outputs.is_team != 'true' |
32 | | - uses: ./.github/actions/setup-bun |
33 | | - |
34 | | - - name: Install dependencies |
35 | | - if: steps.team-check.outputs.is_team != 'true' |
36 | | - run: bun install |
37 | | - |
38 | | - - name: Install opencode |
39 | | - if: steps.team-check.outputs.is_team != 'true' |
40 | | - run: curl -fsSL https://opencode.ai/install | bash |
41 | | - |
42 | | - - name: Build prompt |
43 | | - if: steps.team-check.outputs.is_team != 'true' |
44 | | - env: |
45 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
46 | | - PR_NUMBER: ${{ github.event.pull_request.number }} |
47 | | - run: | |
48 | | - { |
49 | | - echo "Check for duplicate PRs related to this new PR:" |
50 | | - echo "" |
51 | | - echo "CURRENT_PR_NUMBER: $PR_NUMBER" |
52 | | - echo "" |
53 | | - echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)" |
54 | | - echo "" |
55 | | - echo "Description:" |
56 | | - gh pr view "$PR_NUMBER" --json body --jq .body |
57 | | - } > pr_info.txt |
58 | | -
|
59 | | - - name: Check for duplicate PRs |
60 | | - if: steps.team-check.outputs.is_team != 'true' |
61 | | - env: |
62 | | - OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} |
63 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
64 | | - PR_NUMBER: ${{ github.event.pull_request.number }} |
65 | | - run: | |
66 | | - COMMENT=$(bun script/duplicate-pr.ts -f pr_info.txt "Check the attached file for PR details and search for duplicates") |
67 | | -
|
68 | | - if [ "$COMMENT" != "No duplicate PRs found" ]; then |
69 | | - gh pr comment "$PR_NUMBER" --body "_The following comment was made by an LLM, it may be inaccurate:_ |
70 | | -
|
71 | | - $COMMENT" |
72 | | - fi |
73 | | -
|
74 | 8 | add-contributor-label: |
75 | 9 | runs-on: ubuntu-latest |
76 | 10 | permissions: |
@@ -81,15 +15,11 @@ jobs: |
81 | 15 | uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
82 | 16 | with: |
83 | 17 | script: | |
84 | | - const isPR = !!context.payload.pull_request; |
85 | | - const issueNumber = isPR ? context.payload.pull_request.number : context.payload.issue.number; |
86 | | - const authorAssociation = isPR ? context.payload.pull_request.author_association : context.payload.issue.author_association; |
87 | | -
|
88 | | - if (authorAssociation === 'CONTRIBUTOR') { |
| 18 | + if (context.payload.pull_request.author_association === 'CONTRIBUTOR') { |
89 | 19 | await github.rest.issues.addLabels({ |
90 | 20 | owner: context.repo.owner, |
91 | 21 | repo: context.repo.repo, |
92 | | - issue_number: issueNumber, |
| 22 | + issue_number: context.payload.pull_request.number, |
93 | 23 | labels: ['contributor'] |
94 | 24 | }); |
95 | 25 | } |