🔧
DevOps
GitHub
깃허브
세계 최대 코드 호스팅 플랫폼. GitHub Actions으로 CI/CD 제공.
깃허브
세계 최대 코드 호스팅 플랫폼. GitHub Actions으로 CI/CD 제공.
GitHub는 Git 저장소를 호스팅하고 협업 기능을 제공하는 세계 최대의 코드 호스팅 플랫폼입니다. 2008년에 설립되어 2018년 Microsoft에 인수되었으며, 전 세계 1억 명 이상의 개발자가 사용합니다. 오픈소스 프로젝트의 중심지이자 현대 소프트웨어 개발의 핵심 도구입니다.
# .github/workflows/ci.yml
name: CI Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
NODE_VERSION: '20'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: dist/
deploy:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build
path: dist
- name: Deploy to production
run: |
# 배포 스크립트
echo "Deploying to production..."
# .github/workflows/docker.yml
name: Docker Build & Push
on:
push:
tags: ['v*']
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# .github/workflows/release.yml
name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
uses: orhun/git-cliff-action@v2
with:
config: cliff.toml
args: --latest --strip header
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.content }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<!-- .github/PULL_REQUEST_TEMPLATE.md -->
## 변경 사항
-
## 관련 이슈
Closes #
## 체크리스트
- [ ] 테스트 코드 작성
- [ ] 문서 업데이트
- [ ] 로컬에서 테스트 완료
## 스크린샷 (UI 변경 시)
API 키, 비밀번호를 코드에 직접 작성하지 마세요. GitHub Secrets에 저장하고 `${{ secrets.SECRET_NAME }}`으로 참조하세요.
main 브랜치에 직접 푸시를 방지하려면 Branch protection rules를 설정하세요. 필수 리뷰어, 상태 체크 통과 등을 강제할 수 있습니다.
GitHub Actions는 실행 시간에 따라 요금이 청구됩니다. 불필요한 트리거를 줄이고, 캐싱을 활용하세요.
공개 저장소의 Actions 로그는 누구나 볼 수 있습니다. 민감한 정보가 로그에 출력되지 않도록 주의하세요.