-
Notifications
You must be signed in to change notification settings - Fork 64
80 lines (73 loc) · 3.06 KB
/
welcome.yml
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
name: Welcome Comments
permissions:
actions: write
attestations: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
on:
issues:
types: [opened, closed]
pull_request_target:
types: [opened, closed]
jobs:
welcomer:
runs-on: ubuntu-latest
steps:
- name: Auto Welcome on Issues or PRs
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const author = context.payload.sender.login;
const commentBody = (message) => `👋 @${author} 👋\n\n${message}`;
if (context.eventName === 'issues') {
const issue = context.payload.issue;
if (context.payload.action === 'opened') {
const message = `We're thrilled to see you opening an issue! Your input is valuable to us. Don’t forget to fill out our issue template for the best experience. We will look into it soon.`;
github.rest.issues.createComment({
issue_number: issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody(message),
});
} else if (context.payload.action === 'closed') {
const message = `Thanks for closing the issue! We appreciate your updates.`;
github.rest.issues.createComment({
issue_number: issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody(message),
});
}
} else if (context.eventName === 'pull_request_target') {
const pr = context.payload.pull_request;
if (context.payload.action === 'opened') {
const message = `We're delighted to have your pull request! Please take a moment to check our contributing guidelines and ensure you've filled out the PR template for a smooth process. We will review it soon.`;
github.rest.issues.createComment({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody(message),
});
} else if (context.payload.action === 'closed') {
const message = pr.merged
? `🎉 You've just merged your pull request! We're excited to have you in our community. Keep up the fantastic contributions to the project!`
: `Thanks for closing the pull request! Your contributions are valuable to us.`;
github.rest.issues.createComment({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody(message),
});
}
}