GitHub
GitHub
The world's largest code hosting platform. Provides CI/CD through GitHub Actions.
GitHub
The world's largest code hosting platform. Provides CI/CD through GitHub Actions.
GitHub is the world's largest code hosting platform that hosts Git repositories and provides collaboration features. Founded in 2008 and acquired by Microsoft in 2018, it is used by more than 100 million developers worldwide. It is the center of open-source projects and a core tool of modern software development.
# .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 변경 시)
Do not write API keys or passwords directly in your code. Store them in GitHub Secrets and reference them with `${{ secrets.SECRET_NAME }}`.
To prevent direct pushes to the main branch, set up Branch protection rules. You can enforce required reviewers, passing status checks, and more.
GitHub Actions is billed based on execution time. Reduce unnecessary triggers and make use of caching.
Actions logs in public repositories can be viewed by anyone. Take care that sensitive information is not printed to the logs.