From 3f9837fc42be4af55ceb8cb494a884c4b851af41 Mon Sep 17 00:00:00 2001 From: juno-lee Date: Sat, 7 Oct 2023 18:41:22 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20dep=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/assign-reviewer/index.js | 30 ++++++++++++++++++++ .github/actions/assign-reviewer/package.json | 8 ++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/actions/assign-reviewer/index.js create mode 100644 .github/actions/assign-reviewer/package.json diff --git a/.github/actions/assign-reviewer/index.js b/.github/actions/assign-reviewer/index.js new file mode 100644 index 000000000..354366945 --- /dev/null +++ b/.github/actions/assign-reviewer/index.js @@ -0,0 +1,30 @@ +const { Octokit } = require('@octokit/action'); + +// 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); +} diff --git a/.github/actions/assign-reviewer/package.json b/.github/actions/assign-reviewer/package.json new file mode 100644 index 000000000..8a38c96bb --- /dev/null +++ b/.github/actions/assign-reviewer/package.json @@ -0,0 +1,8 @@ +{ + "name": "assign-reviewer", + "version": "1.0.0", + "main": "index.js", + "dependencies": { + "@octokit/action": "^6.0.6" + } +}