forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ppia#20683) * Added developer notification * Made minor changes * Added intermediate env variable * removed name * Added env approach * Added exception in linters
- Loading branch information
1 parent
bb407e3
commit 2f3683c
Showing
2 changed files
with
72 additions
and
1 deletion.
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,70 @@ | ||
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 = 'HardikGoyal2003'; // Update this if the mention needs to change | ||
const prNumber = context.payload.pull_request.number; | ||
let message; | ||
if (prCount === 1) { | ||
message = `Thanks @${author}, and congratulations on your first PR to Oppia! 🎉 🥳\n` + | ||
`Feel free to take up a second issue if you'd like to help out more!\n\n` + | ||
`Developer onboarding lead : @${mention}`; | ||
} else if (prCount === 2) { | ||
message = `@${author} Congratulations on your second merged PR to Oppia! 🎉 🥳\n` + | ||
`Since you've merged two PRs, you might be eligible to join the Oppia dev team as a collaborator. If you'd like to do that, please fill in [this form](https://forms.gle/NxPjimCMqsSTNUgu5). Thanks!\n\n` + | ||
`Developer onboarding lead : @${mention}`; | ||
} | ||
if (prCount === 1 || prCount === 2) { | ||
await github.rest.issues.createComment({ | ||
owner: process.env.OWNER, | ||
repo: process.env.REPO, | ||
issue_number: prNumber, | ||
body: message | ||
}); | ||
} |
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