|
| 1 | +name: Celebrating Initial Contributions |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [closed] |
| 6 | + |
| 7 | +permissions: |
| 8 | + pull-requests: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + comment_on_merged_pull_request: |
| 12 | + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout Repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set Environment Variables |
| 19 | + env: |
| 20 | + AUTHOR: ${{ github.event.pull_request.user.login }} |
| 21 | + REPO: ${{ github.event.repository.name }} |
| 22 | + OWNER: ${{ github.event.repository.owner.login }} |
| 23 | + run: | |
| 24 | + echo "AUTHOR=${AUTHOR}" >> $GITHUB_ENV |
| 25 | + echo "REPO=${REPO}" >> $GITHUB_ENV |
| 26 | + echo "OWNER=${OWNER}" >> $GITHUB_ENV |
| 27 | +
|
| 28 | + - name: Count Merged Pull Requests |
| 29 | + id: count_merged_pull_requests |
| 30 | + uses: actions/github-script@v6 |
| 31 | + with: |
| 32 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + script: | |
| 34 | + const author = process.env.AUTHOR; |
| 35 | + const repo = process.env.REPO; |
| 36 | + const owner = process.env.OWNER; |
| 37 | + const { data } = await github.rest.search.issuesAndPullRequests({ |
| 38 | + q: `repo:${owner}/${repo} type:pr state:closed author:${author}` |
| 39 | + }); |
| 40 | + const prCount = data.items.filter(pr => pr.pull_request.merged_at).length; |
| 41 | + core.exportVariable('PR_COUNT', prCount); |
| 42 | +
|
| 43 | + - name: Comment on the Merged Pull Request |
| 44 | + uses: actions/github-script@v6 |
| 45 | + with: |
| 46 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + script: | |
| 48 | + const prCount = parseInt(process.env.PR_COUNT); |
| 49 | + const author = process.env.AUTHOR; |
| 50 | + const mention = 'adhiamboperes'; |
| 51 | + const prNumber = context.payload.pull_request.number; |
| 52 | +
|
| 53 | + let message; |
| 54 | + if (prCount === 1) { |
| 55 | + message = `✨ **Fantastic work @${author}!** Your very first PR to Oppia has been merged! 🎉🥳\n\n` + |
| 56 | + `You've just taken your first step into open-source, and we couldn’t be happier to have you onboard. 🙌\n` + |
| 57 | + `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` + |
| 58 | + `For any support, feel free to reach out to the developer onboarding lead: @${mention}. Happy coding! 👩💻👨💻`; |
| 59 | + } else if (prCount === 2) { |
| 60 | + message = `👏 **Well done @${author}!** Two PRs merged already! 🎉🥳\n\n` + |
| 61 | + `With your second PR, you're on a roll, and your contributions are already making a difference. 🌟\n` + |
| 62 | + `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` + |
| 63 | + `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! 🚀`; |
| 64 | + } |
| 65 | + |
| 66 | + if (prCount === 1 || prCount === 2) { |
| 67 | + await github.rest.issues.createComment({ |
| 68 | + owner: process.env.OWNER, |
| 69 | + repo: process.env.REPO, |
| 70 | + issue_number: prNumber, |
| 71 | + body: message |
| 72 | + }); |
| 73 | + } |
0 commit comments