-
Notifications
You must be signed in to change notification settings - Fork 132
45 lines (42 loc) · 1.76 KB
/
new-contributor.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
name: New Contributor Action
on:
pull_request_target:
types: [closed]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check-new-contributor:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check new contributor
uses: actions/github-script@v7
with:
script: |
const prAuthor = context.payload.pull_request.user.login;
const prMerger = context.payload.pull_request.merged_by.login;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
const currentPR = context.payload.pull_request.number;
const previouslyMergedPRsByAuthor = await github.paginate(
github.rest.pulls.list,
{
owner: repoOwner,
repo: repoName,
state: 'closed',
per_page: 100
},
(response) => response.data.filter(pr => pr.merged_at != null && pr.user.login === prAuthor && pr.number !== currentPR)
);
if (previouslyMergedPRsByAuthor.length == 0) {
const welcomeMessage = `**Welcome**, @${prAuthor}! 🎉 Thank you for your contribution to the MarkBind project!\n\n@${prMerger}, please remember to add @${prAuthor} as an official contributor to our repository.\n\nSee the full list of contributors [here](https://markbind.org/about.html). ✨`;
github.rest.issues.createComment({
issue_number: currentPR,
owner: repoOwner,
repo: repoName,
body: welcomeMessage
});
}