๐ GitHub Actions ์๋ฒฝ ๊ฐ์ด๋: CI/CD ์๋ํ์ ์์!
“GitHub Actions์ด ๋ญ์ง, ์ ์จ์ผ ํ๋์ง, ๊ทธ๋ฆฌ๊ณ ์ด๋ป๊ฒ ํ์ฉํ๋์ง๋ฅผ ์์ธํ ํํค์ณ ๋ณด์!”
๐ ๋ชฉ์ฐจ
1๏ธโฃ GitHub Actions๋?
2๏ธโฃ GitHub Actions์ ํน์ง
3๏ธโฃ GitHub Actions ์ํฌํ๋ก์ฐ ๊ตฌ์กฐ
4๏ธโฃ ์ฃผ์ ๊ตฌ์ฑ ์์ (์ด๋ฒคํธ, ์์ , ๋จ๊ณ, ์ก์ , ๋ฌ๋)
5๏ธโฃ GitHub Actions ์ฃผ์ ๋ฌธ๋ฒ ๋ฐ ์์
6๏ธโฃ ๊ฒฐ๋ก
1๏ธโฃ GitHub Actions๋?
GitHub Actions๋ GitHub ๋ฆฌํฌ์งํ ๋ฆฌ์์ CI/CD ์๋ํ๋ฅผ ๊ตฌํํ ์ ์๋ ์ํฌํ๋ก์ฐ ๊ธฐ๋ฐ์ ์๋ํ ๋๊ตฌ์ด๋ค.
๐น ์ฝ๋ ํธ์, PR, ๋จธ์ง, ์ด์ ์์ฑ ๋ฑ ๋ค์ํ ์ด๋ฒคํธ๋ฅผ ํธ๋ฆฌ๊ฑฐ๋ก ์คํ ๊ฐ๋ฅ
๐น YAML ํ์ผ์ ์ฌ์ฉํ์ฌ ๊ฐ๋จํ๊ฒ ์ค์ ๊ฐ๋ฅ
๐น GitHub ๋ด์์ ์ง์ ์คํ๋๋ฏ๋ก ์ถ๊ฐ ์ค์ ์์ด ์ฝ๊ฒ ์ฌ์ฉ ๊ฐ๋ฅ
๐ก ์ฝ๊ฒ ๋งํ๋ฉด?
โ๏ธ “์ฝ๋๊ฐ push๋๋ฉด ํ ์คํธ & ๋ฐฐํฌ ์๋ ์คํํด์ค!”
โ๏ธ “PR์ด ์ฌ๋ผ์ค๋ฉด ์ฝ๋ ๋ฆฌ๋ทฐ ์ ์ lint ๊ฒ์ฌ๋ฅผ ์๋์ผ๋ก ๋๋ ค์ค!”
โ๏ธ “๋ฒ๊ทธ ์ด์๊ฐ ์์ฑ๋๋ฉด Slack์ ์๋ฆผ์ ๋ณด๋ด์ค!”
2๏ธโฃ GitHub Actions์ ํน์ง
โ GitHub ๋ค์ดํฐ๋ธ ํตํฉ
โ๏ธ GitHub ๋ฆฌํฌ์งํ ๋ฆฌ์ ๊ธด๋ฐํ๊ฒ ์ฐ๊ฒฐ๋์ด ์์ผ๋ฉฐ, PR, ์ด์, ํธ์ ๋ฑ์ ์ด๋ฒคํธ์ ๋ฐ์ ๊ฐ๋ฅ
โ YAML ๊ธฐ๋ฐ ์ค์
โ๏ธ .github/workflows/ ๋๋ ํฐ๋ฆฌ์ YAML ํ์ผ์ ์์ฑํ์ฌ ๊ฐํธํ๊ฒ ์ํฌํ๋ก์ฐ ์์ฑ
โ ๋ฉํฐ OS ๋ฐ ํ๊ฒฝ ์ง์
โ๏ธ Linux, Windows, macOS์์ ์คํ ๊ฐ๋ฅ (runs-on: ubuntu-latest ๋ฑ)
โ๏ธ ์์ฒด ํธ์คํ ๋ฌ๋(Self-hosted Runner)๋ ๊ฐ๋ฅ
โ ๋ณ๋ ฌ ์คํ ๋ฐ ๋งคํธ๋ฆญ์ค ์ ๋ต ์ง์
โ๏ธ ์ฌ๋ฌ ํ๊ฒฝ์์ ๋ณ๋ ฌ๋ก ์คํ ๊ฐ๋ฅ (matrix๋ฅผ ํ์ฉํ ๋ค์ํ Node.js ๋ฒ์ ํ ์คํธ)
โ ๋ง์ผํ๋ ์ด์ค ์ง์
โ๏ธ GitHub Actions Marketplace์์ ๋ค์ํ ์ก์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅ (uses: ํ์ฉ)
โ ๋น์ฉ ํจ์จ์
โ๏ธ GitHub์์ ๊ธฐ๋ณธ ์ ๊ณต (ํผ๋ธ๋ฆญ ๋ฆฌํฌ์งํ ๋ฆฌ๋ ๋ฌด๋ฃ, ๊ฐ์ธ ๋ฆฌํฌ์งํ ๋ฆฌ๋ ๋ฌด๋ฃ ์ ํ ์์)
3๏ธโฃ GitHub Actions ์ํฌํ๋ก์ฐ ๊ตฌ์กฐ
GitHub Actions์ ์ํฌํ๋ก์ฐ(Workflow) ๊ธฐ๋ฐ์ผ๋ก ์๋ํ๋ค.
๐น ์ํฌํ๋ก์ฐ๋ ํ๋ ์ด์์ **์์ (Job)**์ผ๋ก ๊ตฌ์ฑ
๐น ์์ (Job)์ ์ฌ๋ฌ ๊ฐ์ **๋จ๊ณ(Step)**์ ๊ฐ์ง
๐น ๋จ๊ณ(Step)๋ ํ๋ ์ด์์ **์ก์ (Action)**์ ์คํ
๐ GitHub Actions ์คํ ํ๋ฆ
๐ .github/workflows/
โโโ ๐ง my-workflow.yml
name: My CI Workflow # ์ํฌํ๋ก์ฐ ์ด๋ฆ
on: push # ํธ์๋ ๋ ์คํ
jobs:
test: # ์์
(Job) ์ด๋ฆ
runs-on: ubuntu-latest # ์คํ ํ๊ฒฝ
steps: # ๋จ๊ณ(Steps)
- name: Checkout repository
uses: actions/checkout@v3 # ์ก์
์ฌ์ฉ
- name: Run test
run: npm test # ์ปค๋งจ๋ ์คํ
4๏ธโฃ GitHub Actions ์ฃผ์ ๊ตฌ์ฑ ์์
๐ข 1. ์ด๋ฒคํธ (Event)
์ํฌํ๋ก์ฐ๋ฅผ ์คํ์ํค๋ ํธ๋ฆฌ๊ฑฐ(Trigger) ์ญํ ์ ํ๋ค.
๐น ์ฝ๋ ํธ์ (push)
๐น PR ์์ฑ (pull_request)
๐น ์ด์ ์์ฑ (issues)
๐น ํน์ ์๊ฐ๋ง๋ค ์คํ (schedule)
on:
push:
branches:
- main
๐ก 2. ์์ (Job)
๊ฐ Job์ ๋ ๋ฆฝ์ ์ธ ์คํ ๋จ์์ด๋ฉฐ, ์ฌ๋ฌ ๊ฐ์ Job์ ํ๋์ ์ํฌํ๋ก์ฐ์์ ์คํํ ์ ์๋ค.
๐น ์ฌ๋ฌ Job์ ๋ณ๋ ฌ๋ก ์คํ ๊ฐ๋ฅ
๐น Job ๊ฐ ์์กด ๊ด๊ณ ์ค์ ๊ฐ๋ฅ (needs:)
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build Project
run: npm run build
๐ 3. ๋จ๊ณ (Step)
๊ฐ Job ๋ด๋ถ์์ ์คํ๋๋ ์์ ๋จ์
๐น ์คํฌ๋ฆฝํธ ์คํ ๊ฐ๋ฅ (run:)
๐น ์ก์ ์ฌ์ฉ ๊ฐ๋ฅ (uses:)
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: npm install
๐ต 4. ์ก์ (Action)
GitHub Actions์์ ์ ๊ณตํ๋ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์์ ๋จ์
๐น ๊ณต์ ์ก์ ๋๋ ์ปค์คํ ์ก์ ์ฌ์ฉ ๊ฐ๋ฅ
uses: actions/setup-node@v3
with:
node-version: '16'
๐ฃ 5. ๋ฌ๋ (Runner)
GitHub Actions์ด ์คํ๋๋ ์๋ฒ ํ๊ฒฝ
๐น GitHub์์ ์ ๊ณตํ๋ ํธ์คํ ๋ฌ๋ (runs-on: ubuntu-latest)
๐น ์ง์ ์ค์ ๊ฐ๋ฅํ ์ ํ ํธ์คํ ๋ฌ๋ (self-hosted)
runs-on: ubuntu-latest
5๏ธโฃ GitHub Actions ์ฃผ์ ๋ฌธ๋ฒ ๋ฐ ์์
1๏ธโฃ PR์ด ์์ฑ๋ ๋ Lint & Test ์คํ
name: Lint and Test
on:
pull_request:
branches: [main]
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Run Lint
run: npm run lint
- name: Run Tests
run: npm test
2๏ธโฃ ๋ค์ค OS & Node.js ๋ฒ์ ์์ ํ ์คํธ ์คํ (Matrix Strategy)
name: Matrix Test
on: push
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14, 16, 18]
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run Tests
run: npm test
3๏ธโฃ ๋งค์ผ ์ค์ 6์์ ์๋ ์คํ (Cron Schedule)
name: Daily Job
on:
schedule:
- cron: "0 6 * * *" # UTC ๊ธฐ์ค ์ค์ 6์ ์คํ (ํ๊ตญ ์๊ฐ ์คํ 3์)
jobs:
run-scheduled-task:
runs-on: ubuntu-latest
steps:
- name: Run Scheduled Task
run: echo "Running scheduled task!"
๐ฏ ๊ฒฐ๋ก : GitHub Actions, ์ ์จ์ผ ํ ๊น?
โ GitHub ๋ค์ดํฐ๋ธ ์ง์ → ์ค์ ์ด ๊ฐํธํ๋ค
โ YAML ๊ธฐ๋ฐ → ์ง๊ด์ ์ธ ์ํฌํ๋ก์ฐ ์์ฑ ๊ฐ๋ฅ
โ GitHub Marketplace ํ์ฉ → ๋ค์ํ ์ก์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅ
โ ๋ณ๋ ฌ ์คํ & ๋งคํธ๋ฆญ์ค ์ ๋ต → ํ ์คํธ ์๋ํ ์ต์ ํ ๊ฐ๋ฅ
โ ๋ฌด๋ฃ ํ๋ ์ ๊ณต (ํผ๋ธ๋ฆญ ๋ฆฌํฌ์งํ ๋ฆฌ)
“GitHub Actions๋ฅผ ํ์ฉํ์ฌ, ํจ์จ์ ์ธ CI/CD ํ์ดํ๋ผ์ธ์ ๊ตฌ์ถํด๋ณด์ธ์!” ๐
๐ท ์ ์ค์ ๊ฐ๋ฐ์๊ฐ ๋์ด๋ด ์๋น! ๐ท
'Dev-ops' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ GitLab ์๋ฒฝ ๊ฐ์ด๋ (0) | 2025.03.28 |
---|---|
๐ GitHub Actions CI ์ํฌํ๋ก (0) | 2025.03.27 |
๐ ๋ํ์ ์ธ CI ๋๊ตฌ ์๋ฒฝ ๋น๊ต (0) | 2025.03.25 |
๐ CI/CD ์ํฌํ๋ก์ฐ ์ต์ ํ (0) | 2025.03.23 |
๐ Yarn Berry ์๋ฒฝ ์ ๋ฆฌ: ๊ฐ๋ ๋ถํฐ ์บ์ ๊ด๋ฆฌ๊น์ง! (0) | 2025.03.22 |