Check Positive Reaction on PR Approval #4
Workflow file for this run
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
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: | | |
// 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] | |
for (const comment of comments.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!"); | |
} |