-
Notifications
You must be signed in to change notification settings - Fork 7
201 lines (180 loc) · 7.61 KB
/
Copy pathcontributor-experience.yml
File metadata and controls
201 lines (180 loc) · 7.61 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Contributor Experience
on:
pull_request_target:
types: [opened, closed]
issues:
types: [opened]
permissions:
pull-requests: write
issues: write
jobs:
welcome-first-time-contributor:
name: Welcome First-Time Contributors
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' && github.event.action == 'opened'
steps:
- name: Check if first PR
id: check
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.pull_request.user.login;
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all',
per_page: 100
});
const prsByCreator = prs.filter(pr => pr.user.login === creator);
const isFirstPR = prsByCreator.length === 1;
core.setOutput('is_first_pr', isFirstPR);
return isFirstPR;
- name: Add first-contribution label
if: steps.check.outputs.is_first_pr == 'true'
uses: actions/github-script@v9
with:
script: |
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['first-contribution']
});
- name: Welcome message
if: steps.check.outputs.is_first_pr == 'true'
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.pull_request.user.login;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: 'Welcome to Dependi, @' + creator + '! 🎉\n\nThank you for your first contribution to this project! We really appreciate you taking the time to help improve Dependi.\n\nA maintainer will review your PR soon. In the meantime, please make sure:\n- All CI checks pass (formatting, clippy, tests)\n- Your changes are documented if needed\n- You\'ve filled out the PR template\n\nIf you have any questions, feel free to ask here.\n\nHappy coding! 🚀'
});
thank-merged-contributor:
name: Thank Merged Contributors
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true
steps:
- name: Check if first merged PR
id: check
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.pull_request.user.login;
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
per_page: 100
});
const mergedPRsByCreator = prs.filter(pr =>
pr.user.login === creator && pr.merged_at !== null
);
const isFirstMergedPR = mergedPRsByCreator.length === 1;
core.setOutput('is_first_merged', isFirstMergedPR);
return isFirstMergedPR;
- name: Thank first-time contributor
if: steps.check.outputs.is_first_merged == 'true'
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.pull_request.user.login;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: 'Congratulations on your first merged PR, @' + creator + '! 🎊\n\nYour contribution is now part of Dependi. Thank you for helping make dependency management better for Zed users!\n\nYou\'re now officially a Dependi contributor. We hope to see you again! 💜'
});
welcome-first-issue:
name: Welcome First Issue
runs-on: ubuntu-latest
if: github.event_name == 'issues' && github.event.action == 'opened'
steps:
- name: Check if first issue
id: check
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.issue.user.login;
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
creator: creator,
state: 'all',
per_page: 100
});
const isFirstIssue = issues.length === 1;
core.setOutput('is_first_issue', isFirstIssue);
return isFirstIssue;
- name: Welcome message for first issue
if: steps.check.outputs.is_first_issue == 'true'
uses: actions/github-script@v9
with:
script: |
const creator = context.payload.issue.user.login;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: 'Thanks for opening your first issue, @' + creator + '! 👋\n\nA maintainer will take a look as soon as possible.\n\nWhile you wait, you might find helpful information in:\n- [README](https://github.com/mpiton/zed-dependi#readme) - Features and configuration\n- [CONTRIBUTING.md](https://github.com/mpiton/zed-dependi/blob/main/CONTRIBUTING.md) - How to contribute\n- [Issues](https://github.com/mpiton/zed-dependi/issues) - Questions and bug reports'
});
auto-label-pr:
name: Auto-Label PRs
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' && github.event.action == 'opened'
steps:
- name: Label based on files changed
uses: actions/github-script@v9
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const labels = new Set();
for (const file of files) {
const path = file.filename;
// Documentation
if (path.endsWith('.md') || path.startsWith('docs/')) {
labels.add('documentation');
}
// Parsers
if (path.includes('parsers/')) {
labels.add('parsers');
}
// Registries
if (path.includes('registries/')) {
labels.add('registries');
}
// LSP providers
if (path.includes('providers/')) {
labels.add('lsp');
}
// Vulnerabilities
if (path.includes('vulnerabilities/')) {
labels.add('security');
}
// CI/CD
if (path.startsWith('.github/')) {
labels.add('ci');
}
// Extension
if (path.startsWith('dependi-zed/')) {
labels.add('extension');
}
// Tests
if (path.includes('test') || path.includes('_test.rs')) {
labels.add('tests');
}
}
if (labels.size > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: Array.from(labels)
});
}