From f61044947d53a9534989326f947cba06f5cfce95 Mon Sep 17 00:00:00 2001 From: "daekwon.park" Date: Thu, 6 Aug 2026 13:50:52 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20main/develop=20=EB=A8=B8=EC=A7=80=20?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EC=A0=95?= =?UTF-8?q?=EC=B1=85=20=EA=B2=80=EC=82=AC=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main은 develop/hotfix/*, develop는 hotfix/feature/feat/fix/chore/* 에서만 머지되도록 소스 브랜치를 검사한다. aipub-backend에 적용한 것과 동일한 워크플로우. 조직(ten1010-io)이 현재 GitHub Free 플랜이라 private 저장소에 branch protection/rulesets(Required status check)을 설정할 수 없어, 지금은 머지를 강제로 막지 못하고 PR에 초록/빨강 체크로만 표시된다. GitHub Team 이상으로 업그레이드되면 이 워크플로우를 main/develop의 Required status check로 등록해 실제 강제하면 된다. --- .../workflows/enforce-merge-source-branch.yml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/enforce-merge-source-branch.yml diff --git a/.github/workflows/enforce-merge-source-branch.yml b/.github/workflows/enforce-merge-source-branch.yml new file mode 100644 index 00000000..f5bd931a --- /dev/null +++ b/.github/workflows/enforce-merge-source-branch.yml @@ -0,0 +1,58 @@ +name: Enforce Merge Source Branch + +# main/develop로 향하는 PR의 소스(head) 브랜치가 브랜치 전략에 맞는 패턴인지 검사한다. +# 참고: 이 조직(ten1010-io)은 현재 GitHub Free 플랜이라 private 저장소에서 +# branch protection/rulesets(Required status check)을 설정할 수 없다. 그래서 +# 지금은 이 체크가 머지 버튼을 강제로 막지는 못하고, PR 화면에 초록/빨강으로 +# 표시되어 리뷰어가 육안으로 판단하는 시각적 신호로만 동작한다. GitHub Team +# 이상으로 업그레이드되면 이 워크플로우의 job을 main/develop의 Required status +# check로 등록해 실제 강제가 가능해진다. +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: + - main + - develop + +jobs: + check-source-branch: + runs-on: ubuntu-latest + steps: + - name: Validate source branch against target branch policy + env: + BASE: ${{ github.event.pull_request.base.ref }} + HEAD: ${{ github.event.pull_request.head.ref }} + run: | + echo "target(base): ${BASE}" + echo "source(head): ${HEAD}" + + case "$BASE" in + main) + case "$HEAD" in + develop|hotfix/*) + echo "OK: '${HEAD}' -> main 은 허용된 패턴입니다." + exit 0 + ;; + *) + echo "::error::main 은 develop 또는 hotfix/* 브랜치에서만 머지할 수 있습니다 (현재 소스: ${HEAD})" + exit 1 + ;; + esac + ;; + develop) + case "$HEAD" in + hotfix/*|feature/*|feat/*|fix/*|chore/*) + echo "OK: '${HEAD}' -> develop 은 허용된 패턴입니다." + exit 0 + ;; + *) + echo "::error::develop 은 hotfix/*, feature/*, feat/*, fix/*, chore/* 브랜치에서만 머지할 수 있습니다 (현재 소스: ${HEAD})" + exit 1 + ;; + esac + ;; + *) + echo "정책 대상 브랜치가 아닙니다 (target=${BASE}), 통과합니다." + exit 0 + ;; + esac