|
7 | 7 | permissions: {} |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - agentscan: |
| 10 | + first_time_contributor: |
| 11 | + name: Is first-time contributor |
| 12 | + # GitHub can report first-time contributors as NONE in the event payload. |
11 | 13 | if: >- |
12 | 14 | github.run_attempt == 1 && |
13 | 15 | github.repository == 'nodejs/node' && |
14 | 16 | (github.event.pull_request.author_association == 'FIRST_TIMER' || |
15 | | - github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR') |
| 17 | + github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' || |
| 18 | + github.event.pull_request.author_association == 'NONE') |
| 19 | + runs-on: ubuntu-slim |
| 20 | + permissions: |
| 21 | + pull-requests: read |
| 22 | + outputs: |
| 23 | + eligible: >- |
| 24 | + ${{ |
| 25 | + github.event.pull_request.author_association != 'NONE' || |
| 26 | + steps.recheck.outputs.eligible == 'true' |
| 27 | + }} |
| 28 | + steps: |
| 29 | + - name: Recheck contributor eligibility |
| 30 | + id: recheck |
| 31 | + if: github.event.pull_request.author_association == 'NONE' |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ github.token }} |
| 34 | + NUMBER: ${{ github.event.pull_request.number }} |
| 35 | + run: | |
| 36 | + association=$(gh api "/repos/$GITHUB_REPOSITORY/pulls/$NUMBER" \ |
| 37 | + --jq '.author_association') |
| 38 | + echo "Author association: $association" |
| 39 | +
|
| 40 | + case "$association" in |
| 41 | + FIRST_TIMER|FIRST_TIME_CONTRIBUTOR) |
| 42 | + echo 'eligible=true' >> "$GITHUB_OUTPUT" |
| 43 | + ;; |
| 44 | + *) |
| 45 | + echo 'eligible=false' >> "$GITHUB_OUTPUT" |
| 46 | + ;; |
| 47 | + esac |
| 48 | +
|
| 49 | + agentscan: |
| 50 | + needs: first_time_contributor |
| 51 | + if: needs.first_time_contributor.outputs.eligible == 'true' |
16 | 52 | runs-on: ubuntu-slim |
17 | 53 | permissions: |
18 | 54 | contents: read |
19 | 55 | outputs: |
20 | | - scan_outcome: ${{ steps.agentscan.outcome }} |
21 | | - classification: ${{ steps.agentscan.outputs.classification }} |
22 | | - community_flagged: ${{ steps.agentscan.outputs['community-flagged'] }} |
| 56 | + scan_outcome: ${{ steps.scan.outcome }} |
| 57 | + classification: ${{ steps.scan.outputs.classification }} |
| 58 | + community_flagged: ${{ steps.scan.outputs['community-flagged'] }} |
23 | 59 | steps: |
24 | 60 | - name: Scan contributor activity |
25 | | - id: agentscan |
| 61 | + id: scan |
26 | 62 | # The welcome should still be posted if this advisory scan fails. |
27 | 63 | continue-on-error: true |
28 | 64 | uses: MatteoGabriele/agentscan-action@98202262c925c508d4c1424b1dfbe17ee35b0c02 # v2.4.0 |
|
35 | 71 | honeypot: false |
36 | 72 |
|
37 | 73 | comment: |
38 | | - needs: agentscan |
| 74 | + needs: |
| 75 | + - first_time_contributor |
| 76 | + - agentscan |
| 77 | + if: needs.first_time_contributor.outputs.eligible == 'true' |
39 | 78 | runs-on: ubuntu-slim |
40 | 79 | permissions: |
41 | 80 | pull-requests: write |
|
0 commit comments