From f17994aa269dd8a971b33095cddaf6cadef88a91 Mon Sep 17 00:00:00 2001 From: Zen <107134031+effozen@users.noreply.github.com> Date: Sun, 17 Nov 2024 05:59:16 +0900 Subject: [PATCH] =?UTF-8?q?[ENV][Fix]=20#1=20:=20auto-merge=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=8F=99=EC=9E=91?= =?UTF-8?q?=EC=95=88=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-merge.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index e1ebd862..48f850fc 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -19,27 +19,33 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number, }); - core.setOutput('prResult', JSON.stringify(pr)); + return { prResult: JSON.stringify(pr) } - name: 'Check Approvals and Labels' id: check uses: actions/github-script@v6 with: + prResult: ${{ steps.pr.outputs.prResult }} script: | - const pr = JSON.parse(process.env.PR_RESULT); + const pr = JSON.parse(inputs.prResult); const reviews = await github.rest.pulls.listReviews({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pr.number, }); - const approvals = reviews.data.filter(review => review.state === 'APPROVED'); + const uniqueApprovers = new Set(); + reviews.data.forEach(review => { + if (review.state === 'APPROVED') { + uniqueApprovers.add(review.user.login); + } + }); const hasLabel = pr.labels.some(label => label.name === '확인 요청'); // 메인 브랜치로 향하는 PR인 경우 리뷰어 3명, 다른 브랜치인 경우 2명 필요 - const requiredApprovals = pr.base.ref === 'main' ? 3 : 2; + const requiredApprovals = (pr.base.ref === 'main' || pr.base.ref === 'development') ? 3 : 2; // Check 조건 결과를 출력에 설정 - core.setOutput('result', approvals.length >= requiredApprovals && hasLabel); + return { result : uniqueApprovers.size >= requiredApprovals && hasLabel }; - name: 'Change Label to 작업 완료' if: steps.check.outputs.result == 'true'