Files
vconnect-api/.gitea/workflows/deploy.yml
Kim.KANGHEE 8b1495db28
Some checks failed
Deploy VConnect API / Test Build (push) Successful in 31s
Deploy VConnect API / Deploy to Server (push) Failing after 7s
Update .gitea/workflows/deploy.yml
2025-12-13 23:00:35 +09:00

92 lines
2.4 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 포함 컨테이너 (act_runner + Gitea Actions 필수)
container: node:18-bullseye
steps:
# 1⃣ 내부 네트워크로 직접 Clone (checkout 액션 제거)
- name: Checkout repository (internal)
run: |
echo "📥 Internal git clone start"
git clone --depth 1 https://gitea.mouse84.com/Kim.KANGHEE/vconnect-api.git .
echo "📥 Clone done"
# 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⃣ 기본 테스트 (지금은 echo, 이후 pytest 등으로 교체 가능)
- name: Run basic tests
run: |
echo "✅ Code checkout success"
echo "✅ Python ready"
echo "✅ Dependencies installed"
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 key setup"
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 "🚀 Deploy start"
ssh kdesk84@192.168.0.97 << 'EOF'
set -e
echo "📂 Move to project directory"
cd /data/vconnect-api
echo "📦 Git pull"
git pull origin main
echo "🐍 Activate virtualenv"
source venv/bin/activate
echo "📦 Install dependencies"
pip install -r requirements.txt
echo "🔄 Restart service"
sudo systemctl restart vconnect-api
echo "📋 Service status"
sudo systemctl status vconnect-api --no-pager -l
echo "✅ Deploy finished"
EOF
- name: Deployment Complete
run: echo "🎉 VConnect API deployment completed!"