diff --git a/README.md b/README.md index 26de73c..9c75ece 100644 --- a/README.md +++ b/README.md @@ -102,58 +102,58 @@ jobs: with: github-token: ${{ secrets.SECRET_PAT }} script: | - const prlistConfig = github.pulls.list.endpoint.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - }); - const prList = await github.paginate(prlistConfig); - for (const pr of prList) { - if ( - pr.state === "open" && - !!pr.labels.find( - (label) => label.name === "${{ github.event.inputs.subject }}" - ) - ) { + const prlistConfig = github.pulls.list.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + const prList = await github.paginate(prlistConfig); + for (const pr of prList) { if ( + pr.state === "open" && !!pr.labels.find( - (label) => label.name === "${{ github.event.inputs.currect-label }}" + (label) => label.name === "${{ github.event.inputs.subject }}" ) ) { - await github.pulls.requestReviewers({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr.number, - team_reviewers: ["${{ github.event.inputs.reviewer }}"], - }); - await github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - body: [ - `๐ŸŽ‰ ํ‰๊ฐ€ ๋งค์นญ์ด ๋˜์…จ์Šต๋‹ˆ๋‹ค! ๋ฆฌ๋ทฐ์–ด๋ฅผ ํ™•์ธํ›„ ์•„๋ž˜์˜ ์ฃผ์˜ ์‚ฌํ•ญ์„ ํ™•์ธํ•˜์—ฌ ์ง„ํ–‰ ํ•ด์ฃผ์„ธ์š”!`, - `- โš ๏ธ ํ‰๊ฐ€์‹œ ์ฃผ์˜ ์‚ฌํ•ญ`, - ` - ๋ณธ๊ณผ์ •๊ณผ ๋™์ผ ํ•˜๊ฒŒ ์œ„์—์„œ ํ‹€๋ฆฐ ๊ฒฝ์šฐ ๊ทธ ์ฆ‰์‹œ ํ‰๊ฐ€์ ์ˆ˜ ๋ถ€์—ฌ๋Š” ๋ฉˆ์ถฐ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`, - ` - ํ‰๊ฐ€๋ฅผ ์ง„ํ–‰ ํ• ๋•Œ PR์˜ CodeReview ๊ธฐ๋Šฅ์„ ์ด์šฉํ•ด์„œ \`approve\`๋กœ ๋ฆฌ๋ทฐ๋ฅผ ๋‚จ๊ฒจ์ฃผ์„ธ์š”.`, - ` - \`comment\` ๋กœ ์ž‘์„ฑํ•˜์—ฌ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์Šคํƒญ๋ถ„๋“ค์ด ํ™•์ธํ•˜๋Š”๋ฐ ์–ด๋ ค์›€์„ ๊ฒฉ์Šต๋‹ˆ๋‹ค ใ… ใ… `, - ` - PR ๋ฆฌ๋ทฐ์— ๊ตฌ๊ธ€ ํผ ์ œ์ถœ ํ›„ ๋‚˜์˜ค๋Š” ์ ์ˆ˜ ๊ฒฐ๊ณผ๋ฅผ ๊ผญ ๊ฐ™์ด ์ œ์ถœ ํ•˜์—ฌ์ฃผ์„ธ์š”!`, - ].join("\n"), - }); - } else if ( - !!pr.labels.find( - (label) => label.name === "${{ github.event.inputs.wrong-label }}" - ) - ) { - await github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - body: [ - `๐Ÿ˜ญ ์•ˆํƒ€๊น์ง€๋งŒ ์ œ์ถœ ๊ธฐ๊ฐ„๋‚ด์— ์ •์ƒ์ ์œผ๋กœ ์ œ์ถœ์ด ๋˜์ง€ ์•Š์•„์„œ 0์ ์œผ๋กœ ์ฒ˜๋ฆฌ ๋ฉ๋‹ˆ๋‹ค.`, - `- ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์—๋Š” \`#team_qna\` ์— ๋ฌธ์˜ ํ•ด์ฃผ์„ธ์š”!`, - `- ๋งŒ์•ฝ ๋ฆฌ๋ทฐ๋ฅผ ๋ฐ›๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ ์ฃผ๋ณ€ ๋™๋ฃŒ ๋ถ„๋“ค๊ป˜ ๊ฐœ์ธ์ ์œผ๋กœ ๋ฆฌ๋ทฐ๋ฅผ ์š”์ฒญํ•ด์„œ ์ง„ํ–‰ํ•˜์—ฌ ์ฃผ์„ธ์š”!`, - ].join("\n"), - }); + if ( + !!pr.labels.find( + (label) => label.name === "${{ github.event.inputs.currect-label }}" + ) + ) { + await github.pulls.requestReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + team_reviewers: ["${{ github.event.inputs.reviewer }}"], + }); + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: [ + `๐ŸŽ‰ ํ‰๊ฐ€ ๋งค์นญ์ด ๋˜์…จ์Šต๋‹ˆ๋‹ค! ๋ฆฌ๋ทฐ์–ด๋ฅผ ํ™•์ธํ›„ ์•„๋ž˜์˜ ์ฃผ์˜ ์‚ฌํ•ญ์„ ํ™•์ธํ•˜์—ฌ ์ง„ํ–‰ ํ•ด์ฃผ์„ธ์š”!`, + `- โš ๏ธ ํ‰๊ฐ€์‹œ ์ฃผ์˜ ์‚ฌํ•ญ`, + ` - ๋ณธ๊ณผ์ •๊ณผ ๋™์ผ ํ•˜๊ฒŒ ์œ„์—์„œ ํ‹€๋ฆฐ ๊ฒฝ์šฐ ๊ทธ ์ฆ‰์‹œ ํ‰๊ฐ€์ ์ˆ˜ ๋ถ€์—ฌ๋Š” ๋ฉˆ์ถฐ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`, + ` - ํ‰๊ฐ€๋ฅผ ์ง„ํ–‰ ํ• ๋•Œ PR์˜ CodeReview ๊ธฐ๋Šฅ์„ ์ด์šฉํ•ด์„œ \`approve\`๋กœ ๋ฆฌ๋ทฐ๋ฅผ ๋‚จ๊ฒจ์ฃผ์„ธ์š”.`, + ` - \`comment\` ๋กœ ์ž‘์„ฑํ•˜์—ฌ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์Šคํƒญ๋ถ„๋“ค์ด ํ™•์ธํ•˜๋Š”๋ฐ ์–ด๋ ค์›€์„ ๊ฒฉ์Šต๋‹ˆ๋‹ค ใ… ใ… `, + ` - PR ๋ฆฌ๋ทฐ์— ๊ตฌ๊ธ€ ํผ ์ œ์ถœ ํ›„ ๋‚˜์˜ค๋Š” ์ ์ˆ˜ ๊ฒฐ๊ณผ๋ฅผ ๊ผญ ๊ฐ™์ด ์ œ์ถœ ํ•˜์—ฌ์ฃผ์„ธ์š”!`, + ].join("\n"), + }); + } else if ( + !!pr.labels.find( + (label) => label.name === "${{ github.event.inputs.wrong-label }}" + ) + ) { + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: [ + `๐Ÿ˜ญ ์•ˆํƒ€๊น์ง€๋งŒ ์ œ์ถœ ๊ธฐ๊ฐ„๋‚ด์— ์ •์ƒ์ ์œผ๋กœ ์ œ์ถœ์ด ๋˜์ง€ ์•Š์•„์„œ 0์ ์œผ๋กœ ์ฒ˜๋ฆฌ ๋ฉ๋‹ˆ๋‹ค.`, + `- ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์—๋Š” \`#team_qna\` ์— ๋ฌธ์˜ ํ•ด์ฃผ์„ธ์š”!`, + `- ๋งŒ์•ฝ ๋ฆฌ๋ทฐ๋ฅผ ๋ฐ›๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ ์ฃผ๋ณ€ ๋™๋ฃŒ ๋ถ„๋“ค๊ป˜ ๊ฐœ์ธ์ ์œผ๋กœ ๋ฆฌ๋ทฐ๋ฅผ ์š”์ฒญํ•ด์„œ ์ง„ํ–‰ํ•˜์—ฌ ์ฃผ์„ธ์š”!`, + ].join("\n"), + }); + } } } - } ``` diff --git a/dist/index.js b/dist/index.js index 1566dca..0d90ecf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -155,9 +155,11 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { _e.sent(); core.info("PR " + prNumber + ": wrong submission (too many submissions)"); return [2 /*return*/]; - case 7: + case 7: return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; + case 8: + _e.sent(); subject = config.subjects[subjects[0]]; - if (!(Date.parse(subject.asOfDate) > Date.now())) return [3 /*break*/, 9]; + if (!(Date.parse(subject.asOfDate) > Date.now())) return [3 /*break*/, 10]; return [4 /*yield*/, exports.wrongSubmission(client, prNumber, [wrongLabel_1, REASON.EARLY_SUBMISSION], removeLabels, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- Subject \uC81C\uCD9C \uAE30\uAC04\uC774 \uC544\uB2D9\uB2C8\uB2E4! \uC544\uB798\uC758 \uC815\uBCF4\uB97C \uD655\uC778 \uD574\uC8FC\uC138\uC694! ", @@ -165,12 +167,12 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { "- PR \uC81C\uCD9C \uC2DC\uAC01: " + exports.toLocalString(pr.created_at), "- PR \uB9C8\uC9C0\uB9C9 \uC5C5\uB370\uC774\uD2B8 \uC2DC\uAC01: " + exports.toLocalString(pr.updated_at), ].join("\n"))]; - case 8: + case 9: _e.sent(); core.info("PR " + prNumber + ": early submission"); return [2 /*return*/]; - case 9: - if (!(Date.parse(subject.dueDate) < Date.parse(pr.updated_at))) return [3 /*break*/, 11]; + case 10: + if (!(Date.parse(subject.dueDate) < Date.parse(pr.updated_at))) return [3 /*break*/, 12]; return [4 /*yield*/, exports.wrongSubmission(client, prNumber, [wrongLabel_1, REASON.LATE_SUBMISSION], removeLabels, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83D\uDE2D \uC548\uD0C0\uAE5D\uC9C0\uB9CC \uC11C\uBE0C\uC81D\uD2B8 \uC81C\uCD9C\uAE30\uAC04\uC774 \uC9C0\uB0AC\uC2B5\uB2C8\uB2E4.", @@ -179,11 +181,11 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { "- PR \uC81C\uCD9C \uC2DC\uAC01: " + exports.toLocalString(pr.created_at), "- PR \uB9C8\uC9C0\uB9C9 \uC5C5\uB370\uC774\uD2B8 \uC2DC\uAC01: " + exports.toLocalString(pr.updated_at), ].join("\n"))]; - case 10: + case 11: _e.sent(); core.info("PR " + prNumber + ": late submission"); return [2 /*return*/]; - case 11: + case 12: if (pr.labels.find(function (label) { return label.name === wrongLabel_1; })) { exports.removeLabel(client, prNumber, wrongLabel_1); } @@ -196,9 +198,6 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { reason = _d[_c]; _loop_2(reason); } - return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; - case 12: - _e.sent(); return [4 /*yield*/, exports.addComment(client, prNumber, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83C\uDF89 \uC815\uC0C1\uC801\uC73C\uB85C \uC81C\uCD9C \uB418\uC168\uC2B5\uB2C8\uB2E4! \uD3C9\uAC00 \uB9E4\uCE6D\uC744 \uAE30\uB2EC\uB824\uC8FC\uC138\uC694!", diff --git a/lib/pr-checker.js b/lib/pr-checker.js index bb70846..af581ac 100644 --- a/lib/pr-checker.js +++ b/lib/pr-checker.js @@ -148,9 +148,11 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { _e.sent(); core.info("PR " + prNumber + ": wrong submission (too many submissions)"); return [2 /*return*/]; - case 7: + case 7: return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; + case 8: + _e.sent(); subject = config.subjects[subjects[0]]; - if (!(Date.parse(subject.asOfDate) > Date.now())) return [3 /*break*/, 9]; + if (!(Date.parse(subject.asOfDate) > Date.now())) return [3 /*break*/, 10]; return [4 /*yield*/, exports.wrongSubmission(client, prNumber, [wrongLabel_1, REASON.EARLY_SUBMISSION], removeLabels, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- Subject \uC81C\uCD9C \uAE30\uAC04\uC774 \uC544\uB2D9\uB2C8\uB2E4! \uC544\uB798\uC758 \uC815\uBCF4\uB97C \uD655\uC778 \uD574\uC8FC\uC138\uC694! ", @@ -158,12 +160,12 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { "- PR \uC81C\uCD9C \uC2DC\uAC01: " + exports.toLocalString(pr.created_at), "- PR \uB9C8\uC9C0\uB9C9 \uC5C5\uB370\uC774\uD2B8 \uC2DC\uAC01: " + exports.toLocalString(pr.updated_at), ].join("\n"))]; - case 8: + case 9: _e.sent(); core.info("PR " + prNumber + ": early submission"); return [2 /*return*/]; - case 9: - if (!(Date.parse(subject.dueDate) < Date.parse(pr.updated_at))) return [3 /*break*/, 11]; + case 10: + if (!(Date.parse(subject.dueDate) < Date.parse(pr.updated_at))) return [3 /*break*/, 12]; return [4 /*yield*/, exports.wrongSubmission(client, prNumber, [wrongLabel_1, REASON.LATE_SUBMISSION], removeLabels, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83D\uDE2D \uC548\uD0C0\uAE5D\uC9C0\uB9CC \uC11C\uBE0C\uC81D\uD2B8 \uC81C\uCD9C\uAE30\uAC04\uC774 \uC9C0\uB0AC\uC2B5\uB2C8\uB2E4.", @@ -172,11 +174,11 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { "- PR \uC81C\uCD9C \uC2DC\uAC01: " + exports.toLocalString(pr.created_at), "- PR \uB9C8\uC9C0\uB9C9 \uC5C5\uB370\uC774\uD2B8 \uC2DC\uAC01: " + exports.toLocalString(pr.updated_at), ].join("\n"))]; - case 10: + case 11: _e.sent(); core.info("PR " + prNumber + ": late submission"); return [2 /*return*/]; - case 11: + case 12: if (pr.labels.find(function (label) { return label.name === wrongLabel_1; })) { exports.removeLabel(client, prNumber, wrongLabel_1); } @@ -189,9 +191,6 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { reason = _d[_c]; _loop_2(reason); } - return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; - case 12: - _e.sent(); return [4 /*yield*/, exports.addComment(client, prNumber, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83C\uDF89 \uC815\uC0C1\uC801\uC73C\uB85C \uC81C\uCD9C \uB418\uC168\uC2B5\uB2C8\uB2E4! \uD3C9\uAC00 \uB9E4\uCE6D\uC744 \uAE30\uB2EC\uB824\uC8FC\uC138\uC694!", diff --git a/src/pr-checker.ts b/src/pr-checker.ts index f6862e6..33cde3e 100644 --- a/src/pr-checker.ts +++ b/src/pr-checker.ts @@ -109,6 +109,8 @@ export const run = async () => { return; } + await addLabels(client, prNumber, [subjects[0], currectLabel]); + const subject = config.subjects[subjects[0]]; if (Date.parse(subject.asOfDate) > Date.now()) { @@ -162,8 +164,6 @@ export const run = async () => { } } - await addLabels(client, prNumber, [subjects[0], currectLabel]); - await addComment( client, prNumber,