forked from asyncapi/.github
-
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.
ci: added ping-for-attention command to notify the reviewers (asyncap…
…i#239) Co-authored-by: Khuda Dad Nomani <[email protected]>
- Loading branch information
1 parent
f9776ed
commit bf6ed7d
Showing
3 changed files
with
56 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 |
---|---|---|
|
@@ -138,7 +138,7 @@ jobs: | |
uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 | ||
with: | ||
github_token: ${{ secrets.GH_TOKEN }} | ||
patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml,.github/workflows/bounty-program-commands.yml | ||
patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml,.github/workflows/bounty-program-commands.yml,.github/workflows/please-take-a-look-command.yml | ||
committer_username: asyncapi-bot | ||
committer_email: [email protected] | ||
commit_message: "ci: update of files from global .github repo" | ||
|
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
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,54 @@ | ||
# 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: Please take a Look | ||
|
||
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, '/please-take-a-look') || | ||
contains(github.event.comment.body, '/ptal') || | ||
contains(github.event.comment.body, '/PTAL') | ||
) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for Please Take a Look 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:` | ||
}); | ||
} |