76 lines
2.1 KiB
YAML
76 lines
2.1 KiB
YAML
name: Deploy VConnect API
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
name: Test Build
|
|
runs-on: ubuntu-latest
|
|
container: node:18-bullseye
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 1
|
|
submodules: false
|
|
lfs: false
|
|
|
|
- name: Install Python
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y python3 python3-pip
|
|
python3 --version
|
|
pip3 --version
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip3 install --upgrade pip
|
|
if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi
|
|
|
|
- name: Run basic tests
|
|
run: |
|
|
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
|
|
|
|
# 서버에 배포
|
|
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 배포 완료!" |