CI/CD는 지속적 통합(Continuous Integration)과 지속적 제공/배포(Continuous Delivery/Deployment)를 의미
개발과 배포 과정을 자동화하여 더 빠르고 안정적인 소프트웨어 릴리스를 가능하게 하는 개발 문화 및 실천 방식
GitHub에서 제공하는 CI/CD 자동화 도구
.github/workflows 디렉토리에 워크플로우 정의 파일(.yml)을 추가하여 사용
브랜치에 변경이 생기면 자동으로 정의된 작업 실행
.github/workflows/github-actions.yml자세한 문서: GitHub Actions Quickstart
아래는 Node.js 프로젝트에서 테스트, 빌드, AWS S3 배포를 자동화하는 예시
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Deploy to S3
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
GitHub 저장소의 Actions 탭에서 각 빌드의 성공 여부 및 로그를 확인 가능

