chore: develop -> master ff-only 머지 자동화 액션 추가 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: FF-Only Merge to Master | |
| on: | |
| pull_request_review: | |
| types: [submitted] | |
| jobs: | |
| ff-merge: | |
| if: | | |
| github.event.review.state == 'approved' && | |
| github.event.pull_request.base.ref == 'master' && | |
| github.event.pull_request.head.ref == 'develop' && | |
| github.event.pull_request.state == 'open' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 승인 상태 확인 | |
| id: approvals | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: reviews } = await github.rest.pulls.listReviews({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| }); | |
| const latest = {}; | |
| for (const r of reviews) { | |
| if (r.state !== 'COMMENTED') { | |
| latest[r.user.login] = r.state; | |
| } | |
| } | |
| const values = Object.values(latest); | |
| const approved = values.filter(s => s === 'APPROVED').length >= 1; | |
| const blocked = values.some(s => s === 'CHANGES_REQUESTED'); | |
| core.setOutput('ready', approved && !blocked ? 'true' : 'false'); | |
| - name: Checkout | |
| if: steps.approvals.outputs.ready == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| fetch-depth: 0 | |
| - name: Git 설정 | |
| if: steps.approvals.outputs.ready == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: FF-Only merge develop → master | |
| if: steps.approvals.outputs.ready == 'true' | |
| run: | | |
| git checkout master | |
| git merge --ff-only origin/develop | |
| git push origin master |