update: 2024-10-14_1 #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- 3-tier | |
jobs: | |
build: # 배포 전 테스트 | |
runs-on: ubuntu-22.04 # 우분투 20 이상 | |
services: | |
mysql: | |
image: mysql:8 # MySQL 8 | |
env: | |
MYSQL_ROOT_PASSWORD: 1234 | |
MYSQL_DATABASE: world | |
ports: | |
- 3307:3306 # my.cnf 의 bind-address 옵션 충돌 방지 | |
options: >- | |
--health-cmd="mysqladmin ping -h localhost" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12.3' # Python 3.12.3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '21' # Node.js 21 | |
- name: Build and run Docker Compose | |
run: docker compose -f docker-compose.yaml up --build -d | |
# - name: Run tests | |
# run: docker exec -it fastapi pytest | |
# FastAPI 테스트 (필요에 따라 수정) | |
deploy: # 테스트 후 배포 | |
runs-on: ubuntu-22.04 # 우분투 20 이상 | |
needs: build | |
if: github.ref == 'refs/heads/3-tier' # main 브랜치에서만 배포 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Deploy with Docker Compose | |
run: | | |
docker compose -f docker-compose.yaml down | |
docker compose -f docker-compose.yaml up -d |