Skip to content

Commit

Permalink
Fix oppia#20381 : Added Github Action for developer Onboarding leads (o…
Browse files Browse the repository at this point in the history
…ppia#20683)

* Added developer notification

* Made minor changes

* Added intermediate env variable

* removed name

* Added env approach

* Added exception in linters
  • Loading branch information
HardikGoyal2003 authored Aug 7, 2024
1 parent bb407e3 commit 2f3683c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/developer_onboarding_notification.yml
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
});
}
3 changes: 2 additions & 1 deletion scripts/linters/other_files_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class ThirdPartyLibDict(TypedDict):
'develop_commit_notification.yml',
'pending-review-notification.yml',
'revert-web-wiki-updates.yml',
'frontend_tests.yml'
'frontend_tests.yml',
'developer_onboarding_notification.yml'
)
JOBS_EXEMPT_FROM_MERGE_REQUIREMENT: Final = [
'check_test_suites_to_run'
Expand Down

0 comments on commit 2f3683c

Please sign in to comment.