Skip to content

Commit

Permalink
Add a reminder when contributor is new to ping all contributor bot
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEyo1 authored Apr 11, 2024
1 parent 362f761 commit 889836c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/new-contributor.yml
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
});
}

0 comments on commit 889836c

Please sign in to comment.