update for jmeter #78
This file contains hidden or 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: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Connect & Deploy to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_PRIVATE_KEY }} | |
| script: | | |
| # 1. 시스템 nginx 중지 (도커 nginx와 포트 충돌 방지) | |
| sudo nginx -s stop || true | |
| sudo systemctl stop nginx 2>/dev/null || true | |
| sudo systemctl disable nginx 2>/dev/null || true | |
| # 2. 프로젝트 폴더로 이동 또는 클론 | |
| if [ ! -d "/home/ubuntu/interview-platform" ]; then | |
| git clone https://github.com/${{ secrets.REPO_OWNER }}/${{ secrets.REPO_NAME }} /home/ubuntu/interview-platform | |
| else | |
| cd /home/ubuntu/interview-platform | |
| if [ ! -d ".git" ]; then | |
| git init | |
| git remote add origin https://github.com/${{ secrets.REPO_OWNER }}/${{ secrets.REPO_NAME }} | |
| fi | |
| git reset --hard HEAD | |
| git pull origin main | |
| fi | |
| # 3. .env 파일 반영 | |
| echo "${{ secrets.ENV_FILE_ROOT }}" > /home/ubuntu/interview-platform/.env | |
| echo "${{ secrets.ENV_FILE_FRONT }}" > /home/ubuntu/interview-platform/frontend/.env | |
| # 4. Docker 클린 배포 | |
| cd /home/ubuntu/interview-platform | |
| docker-compose down || true | |
| docker network rm interview-platform_default 2>/dev/null || true | |
| docker network prune -f | |
| docker-compose pull | |
| docker system prune -a --volumes -f | |
| docker-compose build --no-cache | |
| docker-compose up -d | |
| # 5. 이미지 정리 | |
| docker image prune -f |