-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding workflow to check for positive reactions to the github-actions…
…[bot] comment
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
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,55 @@ | ||
name: Check Positive Reaction on PR Approval | ||
|
||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
jobs: | ||
check-reaction: | ||
name: Check for positive reaction on the comment after PR approval | ||
if: startsWith(github.event.pull_request.head.ref, 'fix-comment-check') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for positive reaction on bot's comment | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
// Ensure the review is an approval | ||
if (github.event.review.state !== 'APPROVED') { | ||
console.log("The PR review is not an approval. Exiting."); | ||
return; | ||
} | ||
// Get comments on the PR | ||
const comments = await github.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
let foundReaction = false; | ||
// Find the specific comment from github-actions[bot] and print comment data | ||
for (const comment of comments.data) { | ||
console.log("Comment Data:", comment); // Printing each comment's data | ||
if (comment.user.login === 'github-actions[bot]' && comment.body.includes("Validation steps [CI won't pass without confirming this]")) { | ||
const reactions = await github.reactions.listForIssueComment({ | ||
comment_id: comment.id, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
// Check if there's a thumbs up reaction on the bot's comment | ||
foundReaction = reactions.data.some(reaction => reaction.content === '+1'); | ||
if (foundReaction) { | ||
console.log("Positive reaction detected on the validation comment!"); | ||
break; | ||
} | ||
} | ||
} | ||
if (!foundReaction) { | ||
core.setFailed("Required thumbs-up reaction not found on the validation comment!"); | ||
} |