Skip to content

Commit

Permalink
[ENV][Fix] #1 : auto-merge 정상적으로 동작안되는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
effozen authored Nov 16, 2024
1 parent 0342cae commit f17994a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit f17994a

Please sign in to comment.