Skip to content

Commit

Permalink
ci/cd: PR 리뷰 및 댓글 확인 기능 추가
Browse files Browse the repository at this point in the history
- 작성된 PR 리뷴 및 댓글을 확인하여 고유 사용자 수를 체크합니다.
- 리뷰어 및 댓글 작성자가 충분하지 않으면 머지를 방지합니다.
  • Loading branch information
virtue14 committed Jul 3, 2024
1 parent cd83420 commit 7222e65
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR 리뷰 및 댓글 확인

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review:
types: [submitted]
pull_request_review_comment:
types: [created]

jobs:
check-reviews-and-comments:
runs-on: ubuntu-latest

steps:
- name: 리포지토리 체크아웃
uses: actions/checkout@v2

- name: 풀 리퀘스트 리뷰 및 댓글 가져오기
id: get_reviews_and_comments
run: |
REVIEWS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" | jq -r '.[].user.login' | tr '\n' ' ')
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | jq -r '.[].user.login' | tr '\n' ' ')
ALL_USERS="$REVIEWS $COMMENTS"
echo "ALL_USERS=\"$ALL_USERS\"" >> $GITHUB_ENV
- name: 고유 사용자 확인
run: |
echo "ALL_USERS=$ALL_USERS"
UNIQUE_USERS=$(echo "$ALL_USERS" | tr ' ' '\n' | sort | uniq | wc -l)
echo "Unique Users Count: $UNIQUE_USERS"
if [ "$UNIQUE_USERS" -lt 2 ]; then
echo "고유 리뷰어 및 댓글 작성자가 충분하지 않습니다. 머지 전에 최소 2명의 고유 리뷰어 또는 댓글 작성자가 있어야 합니다."
exit 1
fi
env:
ALL_USERS: ${{ env.ALL_USERS }}

0 comments on commit 7222e65

Please sign in to comment.