Skip to content

Commit

Permalink
Adding workflow to check for positive reactions to the github-actions…
Browse files Browse the repository at this point in the history
…[bot] comment
  • Loading branch information
lucasmlp committed Sep 27, 2023
1 parent 1dcdcf1 commit 53c28df
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/test-positive-check.yaml
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!");
}

0 comments on commit 53c28df

Please sign in to comment.