-
-
Notifications
You must be signed in to change notification settings - Fork 36.6k
147 lines (135 loc) Β· 5.82 KB
/
Copy pathfirst-time-contributor.yml
File metadata and controls
147 lines (135 loc) Β· 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Welcome first-time contributors
on:
pull_request_target:
types: [opened]
permissions: {}
jobs:
first_time_contributor:
name: Is first-time contributor
# GitHub can report first-time contributors as NONE in the event payload.
if: >-
github.run_attempt == 1 &&
github.repository == 'nodejs/node' &&
(github.event.pull_request.author_association == 'FIRST_TIMER' ||
github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' ||
github.event.pull_request.author_association == 'NONE')
runs-on: ubuntu-slim
permissions:
pull-requests: read
outputs:
eligible: >-
${{
github.event.pull_request.author_association != 'NONE' ||
steps.recheck.outputs.eligible == 'true'
}}
steps:
- name: Recheck contributor eligibility
id: recheck
if: github.event.pull_request.author_association == 'NONE'
env:
GH_TOKEN: ${{ github.token }}
NUMBER: ${{ github.event.pull_request.number }}
run: |
started_at=$SECONDS
for delay in 15 30 60 120; do
sleep "$delay"
association=$(gh api "/repos/$GITHUB_REPOSITORY/pulls/$NUMBER" \
--jq '.author_association')
elapsed=$((SECONDS - started_at))
echo "Author association after ${elapsed}s: $association"
case "$association" in
FIRST_TIMER|FIRST_TIME_CONTRIBUTOR)
echo 'eligible=true' >> "$GITHUB_OUTPUT"
exit 0
;;
NONE)
;;
*)
echo 'eligible=false' >> "$GITHUB_OUTPUT"
exit 0
;;
esac
done
echo 'eligible=false' >> "$GITHUB_OUTPUT"
agentscan:
needs: first_time_contributor
if: needs.first_time_contributor.outputs.eligible == 'true'
runs-on: ubuntu-slim
permissions:
contents: read
outputs:
scan_outcome: ${{ steps.scan.outcome }}
classification: ${{ steps.scan.outputs.classification }}
community_flagged: ${{ steps.scan.outputs['community-flagged'] }}
steps:
- name: Scan contributor activity
id: scan
# The welcome should still be posted if this advisory scan fails.
continue-on-error: true
uses: MatteoGabriele/agentscan-action@98202262c925c508d4c1424b1dfbe17ee35b0c02 # v2.4.0
with:
github-token: ${{ github.token }}
mode: silent
scan-pull-requests: true
scan-issues: false
auto-close: false
honeypot: false
comment:
needs:
- first_time_contributor
- agentscan
if: needs.first_time_contributor.outputs.eligible == 'true'
runs-on: ubuntu-slim
permissions:
pull-requests: write
steps:
- name: Welcome first-time contributor
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMBER: ${{ github.event.pull_request.number }}
AGENTSCAN_OUTCOME: ${{ needs.agentscan.outputs.scan_outcome }}
AGENTSCAN_CLASSIFICATION: ${{ needs.agentscan.outputs.classification }}
AGENTSCAN_COMMUNITY_FLAGGED: ${{ needs.agentscan.outputs.community_flagged }}
WELCOME_MESSAGE: >2-
Welcome to Node.js, and thank you for your first contribution!
Before review, please take a moment to read:
* the [guide for first-time contributors](https://github.com/nodejs/node/blob/HEAD/doc/contributing/first-contributions.md)
* the [contribution and automation policies](https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md)
* the [pull request guide](https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md)
* the [AI use policy](https://github.com/nodejs/node/blob/HEAD/doc/contributing/ai-guidelines.md)
* the [Code of Conduct](https://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md)
Please make sure every commit is
[signed off](https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#step-4-commit).
For a first pull request, GitHub Actions require collaborator
approval and Jenkins CI must be started by a collaborator or triager,
so an initial wait is normal.
CAUTION_MESSAGE: >-
> [!CAUTION]
> AgentScan found account activity patterns that may be consistent with
automation. This is a heuristic, not proof that this pull request was
opened by an agent or violates policy. AI-assisted contributions are
permitted, but automated tooling must not open pull requests without
advance approval, and contributors must personally understand, test,
verify, and take responsibility for every submitted change. See the
[AgentScan analysis](https://agentscan.tools/user/${{ github.event.pull_request.user.login }}),
[AI use policy](https://github.com/nodejs/node/blob/HEAD/doc/contributing/ai-guidelines.md),
and
[automation policy](https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md#automation-and-bots)
for additional context.
run: |
add_caution=false
if [[ "$AGENTSCAN_OUTCOME" == "success" ]]; then
case "$AGENTSCAN_CLASSIFICATION" in
mixed|automation)
add_caution=true
;;
esac
if [[ "$AGENTSCAN_COMMUNITY_FLAGGED" == "true" ]]; then
add_caution=true
fi
fi
if [[ "$add_caution" == "true" ]]; then
printf '%s\n\n%s\n' "$WELCOME_MESSAGE" "$CAUTION_MESSAGE"
else
printf '%s\n' "$WELCOME_MESSAGE"
fi | gh pr comment "$NUMBER" --repo "$GITHUB_REPOSITORY" --body-file -