Skip to content

Commit

Permalink
Merge pull request #180 from boostcampwm-2024/feature/env/#1-auto-merโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆge-bug-fix

[ENV][Fix] #1 : auto-merge ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘์•ˆ๋˜๋Š” ๋ฌธ์ œ ์ˆ˜์ •
  • Loading branch information
effozen authored Nov 17, 2024
2 parents 0342cae + f17994a commit a7e2d1f
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 a7e2d1f

Please sign in to comment.