-
Notifications
You must be signed in to change notification settings - Fork 2
♻️ refactor: CI/CD 파이프라인 메모리 최적화 #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,51 +6,51 @@ on: | |||||||||||||||||||||||||
| branches: [main, develop] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| deploy: | ||||||||||||||||||||||||||
| if: github.event.pull_request.merged == true | ||||||||||||||||||||||||||
| # 환경 체크 단계 분리 | ||||||||||||||||||||||||||
| warmup: | ||||||||||||||||||||||||||
| runs-on: self-hosted | ||||||||||||||||||||||||||
| timeout-minutes: 15 | ||||||||||||||||||||||||||
| timeout-minutes: 3 | ||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Environment check | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| echo "=== System Check ===" | ||||||||||||||||||||||||||
| whoami | ||||||||||||||||||||||||||
| docker --version | ||||||||||||||||||||||||||
| free -h # 메모리 상태 사전 체크 | ||||||||||||||||||||||||||
| docker ps # 현재 컨테이너 상태 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| deploy: | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 배포 조건에 머지 여부 확인 로직 추가 필요 deploy:
- needs: warmup # ✅ warmup 완료 후 실행
+ needs: warmup # ✅ warmup 완료 후 실행
+ if: github.event.pull_request.merged == true📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| needs: warmup # ✅ warmup 완료 후 실행 | ||||||||||||||||||||||||||
| runs-on: self-hosted | ||||||||||||||||||||||||||
| timeout-minutes: 10 | ||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||
| uses: actions/checkout@v3 | ||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Deploy to EC2 | ||||||||||||||||||||||||||
| # 스크립트 분리 | ||||||||||||||||||||||||||
| - name: Execute deployment script | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| echo "🚀 Starting deployment..." | ||||||||||||||||||||||||||
| echo "🔄 Branch: ${{ github.ref_name }}" | ||||||||||||||||||||||||||
| echo "🔄 Commit: ${{ github.sha }}" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 메모리 정리 | ||||||||||||||||||||||||||
| echo "🧹 Cleaning up memory..." | ||||||||||||||||||||||||||
| docker system prune -f | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 앱 디렉토리로 코드 복사 | ||||||||||||||||||||||||||
| echo "📂 Copying files..." | ||||||||||||||||||||||||||
| rsync -av --delete \ | ||||||||||||||||||||||||||
| --exclude='.git' \ | ||||||||||||||||||||||||||
| --exclude='node_modules' \ | ||||||||||||||||||||||||||
| --exclude='.next' \ | ||||||||||||||||||||||||||
| ./ /home/ubuntu/coplan/app/ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 배포 디렉토리로 이동 | ||||||||||||||||||||||||||
| # 단순히 스크립트만 실행 | ||||||||||||||||||||||||||
| cd /home/ubuntu/coplan | ||||||||||||||||||||||||||
| chmod +x ./deploy.sh | ||||||||||||||||||||||||||
| ./deploy.sh | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Docker 컨테이너 재시작 | ||||||||||||||||||||||||||
| echo "🔄 Restarting containers..." | ||||||||||||||||||||||||||
| docker compose down | ||||||||||||||||||||||||||
| docker compose up -d --build | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 헬스체크 | ||||||||||||||||||||||||||
| # 헬스체크 | ||||||||||||||||||||||||||
| - name: Health check | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| echo "🏥 Health checking..." | ||||||||||||||||||||||||||
| sleep 15 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if docker ps | grep -q coplan-app; then | ||||||||||||||||||||||||||
| echo "✅ Deployment completed successfully!" | ||||||||||||||||||||||||||
| docker logs --tail 10 coplan-app | ||||||||||||||||||||||||||
| echo "🌐 Service available at: http://15.164.127.149" | ||||||||||||||||||||||||||
| if docker ps | grep -q $DOCKER_CONTAINER_NAME; then | ||||||||||||||||||||||||||
| echo "✅ Deployment completed!" | ||||||||||||||||||||||||||
| docker logs --tail 5 $DOCKER_CONTAINER_NAME | ||||||||||||||||||||||||||
| echo "🌐 https://coplan.work" # ✅ HTTPS | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| if docker ps | grep -q $DOCKER_CONTAINER_NAME; then | |
| echo "✅ Deployment completed!" | |
| docker logs --tail 5 $DOCKER_CONTAINER_NAME | |
| echo "🌐 https://coplan.work" # ✅ HTTPS | |
| if [ -z "${DOCKER_CONTAINER_NAME:-}" ]; then | |
| echo "❌ DOCKER_CONTAINER_NAME이 설정되지 않았습니다." | |
| exit 1 | |
| fi | |
| if docker ps | grep -q "$DOCKER_CONTAINER_NAME"; then | |
| echo "✅ Deployment completed!" | |
| docker logs --tail 5 $DOCKER_CONTAINER_NAME | |
| echo "🌐 https://coplan.work" # ✅ HTTPS |
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml around lines 48 to 51, the script uses the
environment variable $DOCKER_CONTAINER_NAME without quotes or validation, which
can cause errors if the variable is unset or contains spaces. Fix this by
quoting the variable references like "$DOCKER_CONTAINER_NAME" and add a check
before this block to verify that $DOCKER_CONTAINER_NAME is set and non-empty,
exiting with an error message if it is not.
Uh oh!
There was an error while loading. Please reload this page.