π On Pull Request Review #16
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: π 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 }} |