C.W.K.
Stream
Lesson 05 of 05 · published

Protected branch와 review gate

~18 min · protected-branches, review

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

Protected branch 가 정책을 강제로 바꿔

프로덕션 grade repo 가 우발적으로 안 망가지는 이유는 모두가 조심해서가 아니야. 플랫폼이 중요 branch 의 안전하지 않은 연산을 거부해서야. GitHub / GitLab / Bitbucket 의 protected branch 가 룰 — 필수 PR 리뷰, 필수 CI 통과, force-push 금지, signed-commit 요구 — 을 branch 수준에 인코딩해. 한 번 설정하면 maintainer 도 우발적 main force-push 못 해.

모든 main 에 적용할 default 보호 세트: merge 전 PR 요구, 승인 1+ 요구, status check (CI suite) 통과 요구, 새 commit 들어오면 stale 승인 dismiss, force-push 금지, 삭제 금지. 더 큰 팀은 추가: 민감 path 에 CODEOWNERS 리뷰 요구, linear history 요구 (rebase 또는 squash merge 강제), signed commit 요구.

CODEOWNERS 는 path 를 필수 reviewer 에 매핑하는 파일. frontend/auth/* @auth-team 은 auth 코드 건드리는 모든 PR 이 auth 팀 리뷰 필요라는 뜻. branch 보호의 'Require review from Code Owners' 와 결합하면 룰이 강제 — auth 변경을 누가 merge 하든 auth 팀 승인 없이 merge 못 해.

Status check 가 gate 의 나머지 절반. 필수 CI workflow — test, type check, lint, 보안 스캔 — 가 녹색 보고해야 merge 허용. 이게 고전적 '방금 push 함, test 는 결국 통과할 거야' 실수 막아. auto-merge ('체크 통과 시 merge') 와 결합하면 개발자가 auto-merge 켠 PR 만들고 떠나, 플랫폼이 모든 gate 녹색일 때만 통합.

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, 승인 1, 필수 status check, force-push 금지. .github/CODEOWNERS 최소 파일 + path-to-team 매핑 하나. 터미널에서 main 에 force-push 시도해서 거부 메시지 읽어. 필수 체크 끝나기 전에 PR merge 시도, GitHub 가 뭘 허용하는지 관찰. 더 큰 팀에 추가할 룰 하나 적어.

Progress

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

댓글 0

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

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