Git의 기본 명령어와 고급 워크플로우를 익혔다면, 이제 팀과 협업하는 방법을 배울 차례입니다. GitHub Flow로 효율적인 브랜치 전략을 세우고, GitHub Actions로 CI/CD 파이프라인을 자동화하세요.
After learning basic Git commands and advanced workflows, it's time to learn how to collaborate with your team. Set up an efficient branching strategy with GitHub Flow, and automate your CI/CD pipeline with GitHub Actions.
GitHub Flow: 심플한 브랜치 전략 GitHub Flow: Simple Branching Strategy
GitHub Flow는 지속적 배포에 최적화된 가벼운 워크플로우입니다. 복잡한 Git Flow와 달리 main 브랜치 + feature 브랜치 두 가지만 사용합니다.
GitHub Flow is a lightweight workflow optimized for continuous deployment. Unlike complex Git Flow, it only uses main branch + feature branches.
🔄 GitHub Flow 단계 🔄 GitHub Flow Steps
- main에서 브랜치 생성: feature/add-login
- Create branch from main: feature/add-login
- 작업 및 커밋: 의미 있는 단위로 커밋
- Work and commit: Commit in meaningful units
- Pull Request 생성: 리뷰 요청
- Create Pull Request: Request review
- Code Review: 팀원 리뷰 및 피드백
- Code Review: Team review and feedback
- 병합 및 배포: main에 머지 → 자동 배포
- Merge and deploy: Merge to main → Auto deploy
$ git checkout main
$ git pull origin main
# 2. feature 브랜치 생성
$ git checkout -b feature/user-authentication
# 3. 작업 및 커밋
$ git add .
$ git commit -m "feat: 사용자 인증 로직 추가"
# 4. 원격에 푸시
$ git push -u origin feature/user-authentication
# 5. GitHub에서 Pull Request 생성
# → 웹 UI에서 "Compare & pull request" 클릭
$ git checkout main
$ git pull origin main
# 2. Create feature branch
$ git checkout -b feature/user-authentication
# 3. Work and commit
$ git add .
$ git commit -m "feat: add user authentication logic"
# 4. Push to remote
$ git push -u origin feature/user-authentication
# 5. Create Pull Request on GitHub
# → Click "Compare & pull request" in web UI
Pull Request 템플릿 만들기 Creating Pull Request Templates
PR 템플릿을 사용하면 리뷰어가 변경사항을 빠르게 이해할 수 있습니다.
.github/PULL_REQUEST_TEMPLATE.md 파일을 생성하세요.
Using PR templates helps reviewers quickly understand changes.
Create a .github/PULL_REQUEST_TEMPLATE.md file.
## 📋 변경 사항 (Changes)
- [ ] 기능 추가
- [ ] 버그 수정
- [ ] 리팩토링
## 📝 설명 (Description)
## 🧪 테스트 방법 (How to Test)
1.
2.
## 📸 스크린샷 (Screenshots)
## ✅ 체크리스트 (Checklist)
- [ ] 테스트 통과
- [ ] 문서 업데이트
- [ ] Breaking changes 없음
GitHub Actions 기초 GitHub Actions Basics
GitHub Actions는 GitHub에 내장된 CI/CD 도구입니다.
.github/workflows/ 디렉토리에 YAML 파일로 워크플로우를 정의합니다.
GitHub Actions is a built-in CI/CD tool in GitHub.
Define workflows as YAML files in the .github/workflows/ directory.
name: CI Pipeline
# 트리거 조건
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Node.js 설치
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 의존성 설치
run: npm ci
- name: 테스트 실행
run: npm test
- name: 빌드
run: npm run build
name: CI Pipeline
# Trigger conditions
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
자동 배포 워크플로우 Auto Deployment Workflow
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker 빌드
run: docker build -t my-app:${{ github.sha }} .
- name: Docker Hub 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker 푸시
run: docker push my-app:${{ github.sha }}
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker
run: docker build -t my-app:${{ github.sha }} .
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker
run: docker push my-app:${{ github.sha }}
💡 Secrets 설정하기 💡 Setting up Secrets
민감한 정보는 Settings → Secrets and variables → Actions에서 설정합니다.
${{ secrets.SECRET_NAME }}으로 워크플로우에서 참조할 수 있습니다.
Set sensitive information in Settings → Secrets and variables → Actions.
Reference them in workflows using ${{ secrets.SECRET_NAME }}.
Semantic Versioning과 릴리스 Semantic Versioning and Releases
Semantic Versioning (SemVer)은 버전 번호에 의미를 부여하는 규칙입니다.
MAJOR.MINOR.PATCH 형식을 사용합니다.
Semantic Versioning (SemVer) is a set of rules for assigning meaning to version
numbers.
It uses the MAJOR.MINOR.PATCH format.
📦 버전 규칙 📦 Version Rules
- MAJOR: 호환되지 않는 API 변경 (1.0.0 → 2.0.0)
- MAJOR: Incompatible API changes (1.0.0 → 2.0.0)
- MINOR: 하위 호환되는 기능 추가 (1.0.0 → 1.1.0)
- MINOR: Backwards compatible features (1.0.0 → 1.1.0)
- PATCH: 하위 호환되는 버그 수정 (1.0.0 → 1.0.1)
- PATCH: Backwards compatible bug fixes (1.0.0 → 1.0.1)
$ git tag -a v1.2.0 -m "버전 1.2.0 릴리스"
$ git push origin v1.2.0
# 모든 태그 푸시
$ git push --tags
# 태그 목록 확인
$ git tag -l "v1.*"
$ git tag -a v1.2.0 -m "Release version 1.2.0"
$ git push origin v1.2.0
# Push all tags
$ git push --tags
# List tags
$ git tag -l "v1.*"
자동 릴리스 워크플로우 Automated Release Workflow
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
⚠️ GITHUB_TOKEN 권한 ⚠️ GITHUB_TOKEN Permissions
릴리스 생성에는 contents: write 권한이 필요합니다.
Settings → Actions → General → Workflow permissions에서 설정하세요.
Creating releases requires contents: write permission.
Set this in Settings → Actions → General → Workflow permissions.
