Files
vconnect-api/.gitea/workflows/deploy.yml
Kim.KANGHEE 9412f72cb3
Some checks failed
Deploy VConnect API / Test Build (push) Waiting to run
Deploy VConnect API / Deploy to Server (push) Has been cancelled
Update .gitea/workflows/deploy.yml
2025-12-13 22:28:57 +09:00

94 lines
2.3 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Deploy VConnect API
on:
push:
branches:
- main
workflow_dispatch:
jobs:
test:
name: Test Build
runs-on: ubuntu-latest
# Node 기반 컨테이너 (checkout 액션 필수)
container: node:18-bullseye
steps:
# 1⃣ Checkout (최소 옵션으로 최적화)
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: false
lfs: false
# 2⃣ Python 설치
- name: Install Python
run: |
apt-get update
apt-get install -y python3 python3-pip
python3 --version
pip3 --version
# 3⃣ 의존성 설치
- name: Install dependencies
run: |
pip3 install --upgrade pip
if [ -f requirements.txt ]; then
pip3 install -r requirements.txt
fi
# 4⃣ 기본 테스트
- name: Run basic tests
run: |
echo "✅ 코드 체크아웃 성공"
echo "✅ Python 환경 준비 완료"
echo "✅ 의존성 설치 완료"
deploy:
name: Deploy to Server
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy via SSH
run: |
set -e
echo "🔐 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
echo "🚀 서버 배포 시작"
ssh kdesk84@192.168.0.97 << 'EOF'
set -e
echo "📂 프로젝트 디렉토리 이동"
cd /data/vconnect-api
echo "📦 최신 코드 가져오기"
git pull origin main
echo "🐍 가상환경 활성화"
source venv/bin/activate
echo "📦 의존성 업데이트"
pip install -r requirements.txt
echo "🔄 서비스 재시작"
sudo systemctl restart vconnect-api
echo "📋 서비스 상태 확인"
sudo systemctl status vconnect-api --no-pager -l
echo "✅ 배포 완료"
EOF
- name: Deployment Complete
run: echo "🎉 VConnect API 배포 완료!"