Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: added ping-for-attention command to notify the reviewers #239

Merged
merged 10 commits into from
Apr 2, 2024
6 changes: 5 additions & 1 deletion .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ jobs:

- `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
- `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.`
- `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.
- `/ping-for-attention` or `/pfa` or `/ptal` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just go with one way, and ptal is the best one as it is known short, just do ptal and longer version which probably is something like please take a look (probably something to check with urban dictionary)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- `/review` or `/rerequest` - This comment will add the given reviewers to the PR and request them to review the PR. It can be used in two ways.
- `/review @reviewer1 @reviewer2` - This will add the given reviewers to the PR and request them to review the PR.
- `/review` - This will add the default reviewers to the PR and request them to re-review the PR. The default reviewers are the ones who have reviewed the PR before.`
})

create_help_comment_issue:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/ping-for-attention.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This action is centrally managed in https://github.com/asyncapi/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

# It uses Github actions to listen for comments on issues and pull requests and
# if the comment contains /ping-for-attention or /pfa it will add a comment pinging
# the code-owners who have not yet reviewed the pull request

name: ping-for-attention

on:
issue_comment:
types: [created]

jobs:
ping-for-attention:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/ping-for-attention') ||
contains(github.event.comment.body, '/pfa') ||
contains(github.event.comment.body, '/ptal') ||
contains(github.event.comment.body, '/PTAL')
)
runs-on: ubuntu-latest
steps:
- name: Check for Ping for Attention Command
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const prDetailsUrl = context.payload.issue.pull_request.url;
const { data: pull } = await github.request(prDetailsUrl);
const reviewers = pull.requested_reviewers.map(reviewer => reviewer.login);

const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});

const reviewersWhoHaveReviewed = reviews.map(review => review.user.login);

const reviewersWhoHaveNotReviewed = reviewers.filter(reviewer => !reviewersWhoHaveReviewed.includes(reviewer));

if (reviewersWhoHaveNotReviewed.length > 0) {
const comment = reviewersWhoHaveNotReviewed.map(reviewer => `@${reviewer}`).join(' ');
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${comment} Please take a look at this PR. Thanks! :wave:`
});
}