From 2dfa09a7753a60cfd698323bec82fe5f899fd1c3 Mon Sep 17 00:00:00 2001 From: "Kim.KANGHEE" Date: Sat, 13 Dec 2025 20:52:41 +0900 Subject: [PATCH] Update .gitea/workflows/deploy.yml --- .gitea/workflows/deploy.yml | 60 +++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index a31980c..7882954 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -13,15 +13,57 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: List files + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies run: | - echo "=== 파일 목록 ===" - ls -la - - - name: Check Python + pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Run basic tests run: | - echo "=== Python 버전 ===" - python3 --version + echo "✅ 코드 체크아웃 성공" + echo "✅ 의존성 설치 성공" + + deploy: + name: Deploy to Server + runs-on: ubuntu-latest + needs: test + if: github.ref == 'refs/heads/main' + steps: + - name: Deploy via SSH + run: | + # SSH 키 설정 + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H 192.168.0.97 >> ~/.ssh/known_hosts - - name: Success - run: echo "CI/CD 테스트 성공!" \ No newline at end of file + # 서버에 배포 + ssh kdesk84@192.168.0.97 << 'EOF' + echo "=== VConnect API 배포 시작 ===" + cd /data/vconnect-api + + # Git Pull + echo "📦 최신 코드 가져오기..." + git pull origin main + + # 가상환경에서 의존성 업데이트 + echo "📦 의존성 업데이트..." + source venv/bin/activate + pip install -r requirements.txt + + # 서비스 재시작 + echo "🔄 서비스 재시작..." + sudo systemctl restart vconnect-api + + # 상태 확인 + echo "✅ 배포 완료! 서비스 상태:" + sudo systemctl status vconnect-api --no-pager -l + EOF + + - name: Deployment Complete + run: echo "🎉 VConnect API 배포 완료!" \ No newline at end of file