From 1d710816e9ba0ceb706aba3c13d168c33feae286 Mon Sep 17 00:00:00 2001 From: Mayank77maruti <125661248+Mayank77maruti@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:35:57 +0530 Subject: [PATCH 1/3] developer onboarding notification --- .../developer_onboarding_notification.yml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/developer_onboarding_notification.yml diff --git a/.github/workflows/developer_onboarding_notification.yml b/.github/workflows/developer_onboarding_notification.yml new file mode 100644 index 00000000000..4b337807240 --- /dev/null +++ b/.github/workflows/developer_onboarding_notification.yml @@ -0,0 +1,73 @@ + +name: PR Merge Comment + +on: + pull_request_target: + types: [closed] + +permissions: write-all + +jobs: + comment-on-merge: + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set environment variables + env: + AUTHOR: ${{ github.event.pull_request.user.login }} + REPO: ${{ github.event.repository.name }} + OWNER: ${{ github.event.repository.owner.login }} + run: | + echo "AUTHOR=${AUTHOR}" >> $GITHUB_ENV + echo "REPO=${REPO}" >> $GITHUB_ENV + echo "OWNER=${OWNER}" >> $GITHUB_ENV + + - name: Count merged PRs + id: count-prs + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const author = process.env.AUTHOR; + const repo = process.env.REPO; + const owner = process.env.OWNER; + const { data } = await github.rest.search.issuesAndPullRequests({ + q: `repo:${owner}/${repo} type:pr state:closed author:${author}` + }); + const prCount = data.items.filter(pr => pr.pull_request.merged_at).length; + core.exportVariable('PR_COUNT', prCount); + + - name: Comment on the PR + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const prCount = parseInt(process.env.PR_COUNT); + const author = process.env.AUTHOR; + const mention = 'adhiamboperes'; // Update this if the mention needs to change + const prNumber = context.payload.pull_request.number; + + let message; + if (prCount === 1) { + message = `✨ **Fantastic work @${author}!** Your very first PR to Oppia has been merged! 🎉🥳\n\n` + + `You've just taken your first step into open-source, and we couldn’t be happier to have you onboard. 🙌\n` + + `If you're feeling adventurous, why not dive into another issue and keep contributing? The community would love to see more from you! 🚀\n\n` + + `For any support, feel free to reach out to the developer onboarding lead: @${mention}. Happy coding! 👩‍💻👨‍💻`; + } else if (prCount === 2) { + message = `👏 **Well done @${author}!** Two PRs merged already! 🎉🥳\n\n` + + `With your second PR, you're on a roll, and your contributions are already making a difference. 🌟\n` + + `This means you may be eligible to join the Oppia dev team as a collaborator! 🎉 If you're interested, please fill out [this form](https://forms.gle/NxPjimCMqsSTNUgu5) and become an even more integral part of the community. 🌱\n\n` + + `Looking forward to seeing even more contributions from you. The developer onboarding lead: @${mention} is here if you need any help! Keep up the great work! 🚀`; + } + + if (prCount === 1 || prCount === 2) { + await github.rest.issues.createComment({ + owner: process.env.OWNER, + repo: process.env.REPO, + issue_number: prNumber, + body: message + }); + } From beafa6159cc01680f30bd8948139982783ff36d8 Mon Sep 17 00:00:00 2001 From: Mayank77maruti <125661248+Mayank77maruti@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:46:52 +0530 Subject: [PATCH 2/3] suggested changes updated --- .../developer_onboarding_notification.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/developer_onboarding_notification.yml b/.github/workflows/developer_onboarding_notification.yml index 4b337807240..32b141e6f9c 100644 --- a/.github/workflows/developer_onboarding_notification.yml +++ b/.github/workflows/developer_onboarding_notification.yml @@ -1,21 +1,21 @@ - -name: PR Merge Comment +name: Celebrating Initial Contributions on: pull_request_target: types: [closed] -permissions: write-all +permissions: + pull-requests: write jobs: - comment-on-merge: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' + comment_on_merged_pull_request: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - name: Checkout repository + - name: Checkout Repository uses: actions/checkout@v4 - - name: Set environment variables + - name: Set Environment Variables env: AUTHOR: ${{ github.event.pull_request.user.login }} REPO: ${{ github.event.repository.name }} @@ -25,8 +25,8 @@ jobs: echo "REPO=${REPO}" >> $GITHUB_ENV echo "OWNER=${OWNER}" >> $GITHUB_ENV - - name: Count merged PRs - id: count-prs + - name: Count Merged Pull Requests + id: count_merged_pull_requests uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -40,7 +40,7 @@ jobs: const prCount = data.items.filter(pr => pr.pull_request.merged_at).length; core.exportVariable('PR_COUNT', prCount); - - name: Comment on the PR + - name: Comment on the Merged Pull Request uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -70,4 +70,4 @@ jobs: issue_number: prNumber, body: message }); - } + } \ No newline at end of file From 0f8f169adcb5387fb3edd32ec28d1f4e3d161333 Mon Sep 17 00:00:00 2001 From: Mayank77maruti <125661248+Mayank77maruti@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:25:05 +0530 Subject: [PATCH 3/3] recommendations added --- .github/workflows/developer_onboarding_notification.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/developer_onboarding_notification.yml b/.github/workflows/developer_onboarding_notification.yml index 32b141e6f9c..7d8f94cafd6 100644 --- a/.github/workflows/developer_onboarding_notification.yml +++ b/.github/workflows/developer_onboarding_notification.yml @@ -9,7 +9,7 @@ permissions: jobs: comment_on_merged_pull_request: - if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -47,7 +47,7 @@ jobs: script: | const prCount = parseInt(process.env.PR_COUNT); const author = process.env.AUTHOR; - const mention = 'adhiamboperes'; // Update this if the mention needs to change + const mention = 'adhiamboperes'; const prNumber = context.payload.pull_request.number; let message; @@ -70,4 +70,4 @@ jobs: issue_number: prNumber, body: message }); - } \ No newline at end of file + }