-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a reminder when contributor is new to ping all contributor bot
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
}); | ||
} | ||