Skip to content

πŸ‘Œ On Pull Request Review #27

πŸ‘Œ On Pull Request Review

πŸ‘Œ On Pull Request Review #27

name: πŸ‘Œ On Pull Request Review
on:
pull_request_review:
types: [submitted]
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: checkout-branch
uses: actions/checkout@v3
# λͺ¨λ“  λ¦¬λ·°μ½”λ©˜νŠΈκ°€ NIT을 ν¬ν•¨ν•˜λŠ”μ§€ ν™•μΈν•œλ‹€.
- name: check-comment
id: check-comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {data: reviewComments} = await github.rest.pulls.listReviewComments({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
}) ?? [];
const recentComment = reviewComments.at(-1);
const reviewId = recentComment.pull_request_review_id;
const reviewCommentsInThisReview = reviewComments.filter(comment => comment.pull_request_review_id === reviewId);
const TRUNCATE_COMMENT_LENGTH = 30;
let haveAllReviewCommentsContainNIT = true;
for(const comment of reviewCommentsInThisReview) {
const truncatedComment = comment.body.slice(0, TRUNCATE_COMMENT_LENGTH);
const isTruncated = comment.body.length > TRUNCATE_COMMENT_LENGTH;
console.log(truncatedComment + (isTruncated ? '..' : ''));
if(!comment.body.includes('NIT')) haveAllReviewCommentsContainNIT = false;
}
console.log(haveAllReviewCommentsContainNIT ? "πŸ‘πŸ» All review comments contain NIT(Not Important Though)" : "πŸ™‡ Some review comments says Need To Change");
if(haveAllReviewCommentsContainNIT) return true;
else return false;
# μ–΄λ–€ 리뷰 μ½”λ©˜νŠΈκ°€ NIT을 ν¬ν•¨ν•˜μ§€ μ•ŠλŠ”λ‹€λ©΄, 변경이 ν•„μš”ν•˜λ―€λ‘œ PR을 draft μƒνƒœλ‘œ λ§Œλ“ λ‹€.
- name: make-this-pr-to-draft
if: ${{ steps.check-comment.outputs.result == 'false' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr ready --undo ${{ github.event.pull_request.number }}