11name : FF-Only Merge to Master
22
33on :
4- pull_request_review :
5- types : [submitted ]
4+ pull_request :
5+ types : [labeled ]
66 check_suite :
77 types : [completed]
88
99jobs :
1010 ff-merge :
1111 if : |
12- github.event_name == 'pull_request_review' ||
12+ ( github.event_name == 'pull_request' && github.event.label.name == 'ready-to-merge') ||
1313 (github.event_name == 'check_suite' && github.event.check_suite.conclusion == 'success')
1414 runs-on : ubuntu-latest
1515
@@ -21,16 +21,12 @@ jobs:
2121 script : |
2222 let prNumber, headSha;
2323
24- if (context.eventName === 'pull_request_review ') {
24+ if (context.eventName === 'pull_request ') {
2525 const pr = context.payload.pull_request;
2626 if (pr.base.ref !== 'master' || pr.head.ref !== 'develop' || pr.state !== 'open') {
2727 core.setOutput('ready', 'false');
2828 return;
2929 }
30- if (context.payload.review.state !== 'approved') {
31- core.setOutput('ready', 'false');
32- return;
33- }
3430 prNumber = pr.number;
3531 headSha = pr.head.sha;
3632 } else {
@@ -56,25 +52,15 @@ jobs:
5652 }
5753 }
5854
59- // 승인 상태 확인
60- const { data: reviews } = await github.rest.pulls.listReviews ({
55+ // ready-to-merge 레이블 확인
56+ const { data: pr } = await github.rest.pulls.get ({
6157 owner: context.repo.owner,
6258 repo: context.repo.repo,
6359 pull_number: prNumber,
6460 });
6561
66- const latest = {};
67- for (const r of reviews) {
68- if (r.state !== 'COMMENTED') {
69- latest[r.user.login] = r.state;
70- }
71- }
72-
73- const values = Object.values(latest);
74- const approved = values.filter(s => s === 'APPROVED').length >= 1;
75- const blocked = values.some(s => s === 'CHANGES_REQUESTED');
76-
77- if (!approved || blocked) {
62+ const hasLabel = pr.labels.some(l => l.name === 'ready-to-merge');
63+ if (!hasLabel) {
7864 core.setOutput('ready', 'false');
7965 return;
8066 }
@@ -120,9 +106,9 @@ jobs:
120106 APPROVED_SHA="${{ steps.validate.outputs.head_sha }}"
121107 CURRENT_SHA=$(git rev-parse origin/develop)
122108 if [ "$APPROVED_SHA" != "$CURRENT_SHA" ]; then
123- echo "develop이 승인 이후 변경되었습니다."
124- echo " 승인된 SHA: $APPROVED_SHA"
125- echo " 현재 SHA: $CURRENT_SHA"
109+ echo "레이블 부착 이후 develop이 변경되었습니다."
110+ echo " 레이블 시점 SHA: $APPROVED_SHA"
111+ echo " 현재 SHA: $CURRENT_SHA"
126112 exit 1
127113 fi
128114
0 commit comments