본문 바로가기
C.W.K.
Stream
Lesson 05 of 05 · published

Protected branch와 review gate

~18 min · protected-branches, review

Level 0추적 전 새싹
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Protected branch는 정책을 실제 거부 규칙으로 바꿔

운영 수준의 repo가 우연히 망가지지 않는 이유는 모두가 늘 조심해서가 아니야. 플랫폼이 중요한 branch의 위험한 연산을 거부하기 때문이야. GitHub, GitLab, Bitbucket의 protected branch는 필수 PR review, CI 통과, force-push 금지, signed commit 같은 규칙을 branch 수준에 새겨. 한 번 설정하면 maintainer도 실수로 main을 force-push할 수 없어.

모든 main에 둘 만한 기본 보호 묶음은 이래. merge 전 PR과 한 명 이상의 승인, status check 통과를 요구하고, 새 commit이 오면 오래된 승인을 무효화하며, force-push와 삭제를 막아. 큰 팀이라면 민감한 path에 CODEOWNERS review를 요구하고, rebase나 squash merge로 직선 이력을 강제하거나 signed commit을 요구할 수 있어.

CODEOWNERS는 path를 필수 검토자에게 연결하는 파일이야. frontend/auth/* @auth-team은 auth 코드를 건드리는 모든 PR에 auth team review가 필요하다는 뜻이지. branch 보호의 'Require review from Code Owners'와 결합하면 누가 merge 버튼을 눌러도 auth team 승인 없이는 통과할 수 없어.

Status check가 관문의 나머지 절반이야. test, type check, lint, 보안 scan 같은 필수 CI가 녹색을 보고해야 merge할 수 있어. '방금 push했지만 test는 아마 통과하겠지'라는 고전적인 실수를 막아주지. auto-merge와 결합하면 개발자는 PR에 자동 merge를 켜고 떠날 수 있고, 플랫폼은 모든 조건이 녹색일 때만 통합해.

Code

추천 GitHub branch protection (web)·text
Settings → Branches → `main` 에 룰 추가:

[x] Require a pull request before merging
    [x] Require approvals (1+)
    [x] Dismiss stale pull request approvals when new commits are pushed
    [x] Require review from Code Owners
[x] Require status checks to pass before merging
    [x] Require branches to be up to date before merging
    Required checks: ci/test, ci/lint, ci/typecheck
[x] Require conversation resolution before merging
[x] Require signed commits
[x] Require linear history
[x] Restrict who can push to matching branches (admins only)
[x] Do not allow force pushes
[x] Do not allow deletions
Repo root 의 CODEOWNERS 파일·text
# .github/CODEOWNERS
# 순서 중요 — 마지막 매칭 패턴 승.

# 모든 것의 default reviewer
*       @core-maintainer

# Auth 코드는 auth team 필요
/backend/auth/         @auth-team
/frontend/src/auth/    @auth-team

# Infra 변경은 platform team
/infra/                @platform-team
*.tf                   @platform-team

# Docs 는 docs team 만
/docs/                 @docs-team

External links

Exercise

admin 권한이 있는 repo의 main에 branch 보호를 설정해. 적어도 PR 필수, 승인 한 명, 필수 status check, force-push 금지를 넣어. .github/CODEOWNERS에 path와 team을 잇는 규칙도 하나 작성해. 터미널에서 main으로 force-push해 거부 message를 읽고, 필수 check가 끝나기 전에 PR merge도 시도해 GitHub가 무엇을 막는지 관찰해. 더 큰 팀이라면 추가할 규칙 하나를 적어봐.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.