diff --git a/.github/workflows/PICK_REVIEWER.yml b/.github/workflows/PICK_REVIEWER.yml index d1d57f87..42bc1dae 100644 --- a/.github/workflows/PICK_REVIEWER.yml +++ b/.github/workflows/PICK_REVIEWER.yml @@ -20,10 +20,33 @@ jobs: script: | const fs = require('fs'); const developers = JSON.parse(fs.readFileSync(`${{ github.workspace }}/reviewers.json`)); - const randomReviewer = developers[Math.floor(Math.random() * developers.length)]; - const comment = `πŸŽ‰ @${randomReviewer} λ‹˜ 랜덀 λ¦¬λ·°μ–΄λ‘œ μ„ μ •λ˜μ…¨μŠ΅λ‹ˆλ‹€! 리뷰λ₯Ό λΆ€νƒλ“œλ¦½λ‹ˆλ‹€. πŸ™` - core.setOutput('comment', comment) // output 을 μ„ΈνŒ…ν•©λ‹ˆλ‹€ - core.setOutput('reviewer', randomReviewer) // core.setOutput(이름, κ°’) + + // κ²ΉμΉ˜μ§€ μ•ŠλŠ” 두λͺ…μ˜ 랜덀 리뷰어 선택 + if(developers?.length == 0) { + core.setOutput('comment', '리뷰어가 μ—†μŠ΅λ‹ˆλ‹€. 리뷰어λ₯Ό μΆ”κ°€ν•΄μ£Όμ„Έμš”.') + } + + if(developers?.length == 1) { + const randomReviewer = developers[0]; + const comment = `πŸŽ‰ @${randomReviewer} λ‹˜ 랜덀 λ¦¬λ·°μ–΄λ‘œ μ„ μ •λ˜μ…¨μŠ΅λ‹ˆλ‹€! 리뷰λ₯Ό λΆ€νƒλ“œλ¦½λ‹ˆλ‹€. πŸ™` + core.setOutput('comment', comment) + core.setOutput('reviewer', randomReviewer) + } + + if(developers?.length > 1) { + const randomReviewer = developers[Math.floor(Math.random() * developers.length)]; + let randomReviewer2; + while(true) { + randomReviewer2 = developers[Math.floor(Math.random() * developers.length)]; + if(randomReviewer != randomReviewer2) { + break; + } + } + const comment = `πŸŽ‰ @${randomReviewer}, @${randomReviewer2} λ‹˜ 랜덀 λ¦¬λ·°μ–΄λ‘œ μ„ μ •λ˜μ…¨μŠ΅λ‹ˆλ‹€! 리뷰λ₯Ό λΆ€νƒλ“œλ¦½λ‹ˆλ‹€. πŸ™` + core.setOutput('comment', comment) + core.setOutput('reviewer', randomReviewer) + core.setOutput('reviewer2', randomReviewer2) + } - name: comment PR uses: mshick/add-pr-comment@v1 @@ -36,5 +59,5 @@ jobs: - name: Add Pull Request Reviewer uses: madrapps/add-reviewers@v1 with: - reviewers: ${{ steps.pick_random_reviwer.outputs.reviewer }} + reviewers: ${{ steps.pick_random_reviwer.outputs.reviewer }}, ${{ steps.pick_random_reviwer.outputs.reviewer2 }} token: ${{ secrets.GITHUB_TOKEN }} diff --git a/reviewers.json b/reviewers.json new file mode 100644 index 00000000..daf9c7ff --- /dev/null +++ b/reviewers.json @@ -0,0 +1,3 @@ +{ + "developers": ["hanagertrudekim", "HAEROOL", "hoooooony", "MinGu-Jeong", "dooohun"] +} \ No newline at end of file