Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI/CD Pipeline

on:
push:
branches: [ "성현준/main", "main", "성현준/8주차" ]
pull_request:
branches: [ "성현준/main", "main", "성현준/8주차" ]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
# 1. 코드 체크아웃
- name: Checkout code
uses: actions/checkout@v3

# 2. application.yml 파일 생성 (Secret에서)
- name: Create application.yml from secret
run: |
echo "${{ secrets.APPLICATION_YML }}" > blog_manage/src/main/resources/application.yml

# 3. Docker Compose로 빌드 및 실행 (cd 명령어 필수!)
- name: Run docker-compose
run: |
cd ${{ github.workspace }}/blog_manage
docker compose up -d --build

# 4. 애플리케이션 헬스 체크
- name: Health check
run: |
sleep 30
curl -f http://localhost:8080/actuator/health || echo "Health check failed"

# 5. 로그 확인
- name: Show logs
if: always()
run: |
cd ${{ github.workspace }}/blog_manage
docker compose logs
47 changes: 47 additions & 0 deletions blog_manage/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
services:
# MySQL 데이터베이스
mysql:
image: mysql:8.0
container_name: blog_mysql
environment:
MYSQL_ROOT_PASSWORD: 2323
MYSQL_DATABASE: leetsBlog
TZ: Asia/Seoul
ports:
- "3307:3306"
volumes:
- mysql_data:/var/lib/mysql
networks:
- blog_network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5

# Spring Boot 애플리케이션 (Dockerfile로 빌드)
app:
build:
context: .
dockerfile: Dockerfile
container_name: blog_app
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/leetsBlog?serverTimezone=Asia/Seoul
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: 2323
depends_on:
mysql:
condition: service_healthy
networks:
- blog_network
restart: unless-stopped

volumes:
mysql_data:

networks:
blog_network:
driver: bridge