From 6007744882c75d9126085d96ce2b04f4369bf1f8 Mon Sep 17 00:00:00 2001 From: Mayank Gupta <91688667+Maykkkk@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:43:54 +0530 Subject: [PATCH] Added Github Workflow for Greeting contributor on their first PR merge (#480) * ci * Update .github/workflows/greet_on_first_merge.yml Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com> * Update Layout.tsx --------- Co-authored-by: Benjamin Granados <40007659+benjagm@users.noreply.github.com> --- .github/workflows/greet_on_first_merge.yml | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/greet_on_first_merge.yml diff --git a/.github/workflows/greet_on_first_merge.yml b/.github/workflows/greet_on_first_merge.yml new file mode 100644 index 0000000000..8864f35cc1 --- /dev/null +++ b/.github/workflows/greet_on_first_merge.yml @@ -0,0 +1,38 @@ +name: Greet on User First PR Merge + +on: + pull_request: + types: [closed] + +jobs: + greet: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const prNumber = context.payload.pull_request.number; + const authorLogin = context.payload.pull_request.user.login; + + const firstPR = await github.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_requests: { + state: 'closed', + author: authorLogin, + }, + }); + + console.log(firstPR.data.length); + + if (firstPR.data.length === 1) { + const greetingMessage = ` Congratulations, @${authorLogin} for your first pull request merge in this repository! 🎉🎉. Thanks for your contribution to JSON Schema! `; + + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: greetingMessage + }); + }