-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { Octokit } = require('@octokit/core'); | ||
|
||
// TODO: env로 빼기 | ||
const reviewers = ['juno7803', 'Tekiter', 'NamJwong', 'seojisoosoo']; | ||
|
||
// 랜덤 리뷰어 선택 | ||
const selectedReviewer = reviewers[Math.floor(Math.random() * reviewers.length)]; | ||
|
||
// TODO: env로 빼기 | ||
const authToken = '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'; | ||
const owner = process.env.GITHUB_OWNER; | ||
const repo = process.env.REPO_NAME; | ||
const prNumber = process.env.PR_NUMBER; | ||
|
||
const octokit = new Octokit({ auth: authToken }); | ||
|
||
try { | ||
await octokit.request(`POST /repos/${owner}/${repo}/pulls/${prNumber}/requested_reviewers`, { | ||
owner, | ||
repo, | ||
pull_number: prNumber, | ||
reviewers: [selectedReviewer], | ||
headers: { | ||
'X-GitHub-Api-Version': '2022-11-28', | ||
}, | ||
}); | ||
console.log(`${selectedReviewer}를 리뷰어로 선정했어요!`); | ||
} catch (error) { | ||
console.error('리뷰어 지정 과정에서 오류가 발생했어요.\n', (error.response && error.response.data) || error.message); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Assign Random Reviewer | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, ready_for_review] | ||
|
||
jobs: | ||
assign_reviewer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install Dependencies | ||
run: npm install @octokit/core | ||
|
||
- name: Assign Reviewer | ||
run: node .github/scripts/randomReviewer.js | ||
env: | ||
GITHUB_OWNER: ${{ github.repository_owner }} | ||
GITHUB_REPOSITORY: ${{ github.repository }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} |