-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathwelcomeScript.js
More file actions
72 lines (59 loc) · 2.44 KB
/
Copy pathwelcomeScript.js
File metadata and controls
72 lines (59 loc) · 2.44 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
module.exports = async ({ github, context }) => {
const owner = context.repo.owner;
const repo = context.repo.repo;
const issueNumber = context.issue.number;
const eventName = context.eventName;
const ghUsername = context.payload.sender.login;
try {
const issueAssociation =
context.payload.issue?.author_association;
if (
eventName === 'issues' &&
issueAssociation === 'NONE'
) {
// Verify this is truly their first issue (listForRepo returns PRs too)
const userIssues = await github.rest.issues.listForRepo({
owner,
repo,
state: 'all',
creator: ghUsername,
per_page: 10
});
const actualIssues = userIssues.data.filter(issue => !issue.pull_request);
if (actualIssues.length === 1) {
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `👋 Thanks for opening your first issue, @${ghUsername}!
We appreciate your contribution and are excited to have you here. Please make sure to follow the contribution guidelines and provide as much detail as possible.
To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community:
https://discord.gg/QueQN83wn
Looking forward to collaborating with you!`
});
}
}
const prAssociation =
context.payload.pull_request?.author_association;
if (
eventName === 'pull_request_target' &&
(
prAssociation === 'FIRST_TIMER' ||
prAssociation === 'FIRST_TIME_CONTRIBUTOR'
)
) {
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `🎉 Thanks for your first contribution, @${ghUsername}!
We're excited to have you here. A maintainer will review your PR soon. Please check CI results and review any feedback if needed.
To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community:
https://discord.gg/QueQN83wn
Looking forward to collaborating with you!`
});
}
} catch (error) {
console.error(error);
}
};