Skip to content

Commit 8d5b402

Browse files
committed
chore: develop -> master ff-only 머지 자동화 액션 추가
1 parent c7407b9 commit 8d5b402

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/ff-merge.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: FF-Only Merge to Master
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
ff-merge:
9+
if: |
10+
github.event.review.state == 'approved' &&
11+
github.event.pull_request.base.ref == 'master' &&
12+
github.event.pull_request.head.ref == 'develop' &&
13+
github.event.pull_request.state == 'open'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: 승인 상태 확인
18+
id: approvals
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const { data: reviews } = await github.rest.pulls.listReviews({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
pull_number: context.payload.pull_request.number,
26+
});
27+
28+
const latest = {};
29+
for (const r of reviews) {
30+
if (r.state !== 'COMMENTED') {
31+
latest[r.user.login] = r.state;
32+
}
33+
}
34+
35+
const values = Object.values(latest);
36+
const approved = values.filter(s => s === 'APPROVED').length >= 1;
37+
const blocked = values.some(s => s === 'CHANGES_REQUESTED');
38+
39+
core.setOutput('ready', approved && !blocked ? 'true' : 'false');
40+
41+
- name: Checkout
42+
if: steps.approvals.outputs.ready == 'true'
43+
uses: actions/checkout@v4
44+
with:
45+
token: ${{ secrets.PAT }}
46+
fetch-depth: 0
47+
48+
- name: Git 설정
49+
if: steps.approvals.outputs.ready == 'true'
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
- name: FF-Only merge develop → master
55+
if: steps.approvals.outputs.ready == 'true'
56+
run: |
57+
git checkout master
58+
git merge --ff-only origin/develop
59+
git push origin master

0 commit comments

Comments
 (0)