πfix: μλ¬ νμ΄μ§ 리λ€μ΄λνΈ λ¬Έμ μμ #58
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: | |
| pull_request: | |
| types: [closed] | |
| branches: [main, develop] | |
| env: | |
| DOCKER_CONTAINER_NAME: coplan-app | |
| jobs: | |
| warmup: | |
| # π‘οΈ λ¨Έμ§λ κ²½μ°μλ§ μ€ν | |
| if: github.event.pull_request.merged == true | |
| runs-on: self-hosted | |
| timeout-minutes: 3 | |
| steps: | |
| - name: Environment check | |
| run: | | |
| echo "=== Deployment System Check ===" | |
| echo "π Merged PR: ${{ github.event.pull_request.title }}" | |
| echo "π€ Author: ${{ github.event.pull_request.user.login }}" | |
| echo "π From: ${{ github.event.pull_request.head.ref }} β ${{ github.event.pull_request.base.ref }}" | |
| echo "π Commit: ${{ github.event.pull_request.merge_commit_sha }}" | |
| echo "" | |
| echo "π₯οΈ System Status:" | |
| whoami | |
| docker --version | |
| free -h | |
| echo "" | |
| echo "π³ Container Status:" | |
| docker ps | |
| deploy: | |
| needs: warmup | |
| runs-on: self-hosted | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Execute deployment script | |
| run: | | |
| echo "π Starting deployment..." | |
| echo "π Branch: ${{ github.ref_name }}" | |
| echo "π Commit: ${{ github.sha }}" | |
| echo "π¦ PR: #${{ github.event.pull_request.number }}" | |
| # deploy.sh μ€ν | |
| cd /home/ubuntu/coplan | |
| chmod +x ./deploy.sh | |
| ./deploy.sh | |
| - name: Health check | |
| run: | | |
| echo "π₯ Health checking..." | |
| sleep 15 | |
| if docker ps | grep -q $DOCKER_CONTAINER_NAME; then | |
| echo "β Deployment completed successfully!" | |
| echo "π Container status:" | |
| docker ps | grep $DOCKER_CONTAINER_NAME | |
| echo "" | |
| echo "π Recent logs:" | |
| docker logs --tail 5 $DOCKER_CONTAINER_NAME | |
| echo "" | |
| echo "π Service available at: https://coplan.work" | |
| else | |
| echo "β Deployment failed!" | |
| echo "π Checking container logs..." | |
| docker logs $DOCKER_CONTAINER_NAME 2>/dev/null || echo "No container logs available" | |
| echo "π Checking system status..." | |
| docker ps -a | |
| free -h | |
| exit 1 | |
| fi |