-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (42 loc) · 2.04 KB
/
on-pull-request-review-comment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 }}