본문 바로가기
Q&A2022년 3월 10일1분 읽기

GitHub Actions CI/CD 기본 설정법

김
김민수
조회 1304댓글 1

GitHub Actions로 CI/CD를 처음 구축하려고 합니다. 기본적인 설정 방법을 알려주세요.

댓글 1

김김영삼4년 전

GitHub Actions 기본 워크플로우:

# .github/workflows/ci.yml
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- run: npm ci
- run: npm test
- run: npm run build

deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run build
- name: Deploy
run: |
rsync -avz ./dist/ user@server:/var/www/

핵심:

  • on — 트리거 조건 (push, PR, schedule 등)
  • jobs — 병렬 실행 가능한 작업 단위
  • needs — 의존성 (test 통과 후 deploy)
  • secrets — Settings → Secrets에 민감 정보 저장
Ctrl+Enter로 등록