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 89476bf
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/test-positive-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check Positive Reaction on PR Approval

on:
pull_request_review:
types: [submitted]

jobs:
check-reaction:
name: Check for positive reaction on the comment
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: |
// 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 89476bf

Please sign in to comment.