Update .gitea/workflows/deploy.yml
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
name: Deploy VConnect API
|
name: Deploy VConnect API
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -9,8 +10,12 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
name: Test Build
|
name: Test Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Node 기반 컨테이너 (checkout 액션 필수)
|
||||||
container: node:18-bullseye
|
container: node:18-bullseye
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# 1️⃣ Checkout (최소 옵션으로 최적화)
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@@ -18,6 +23,7 @@ jobs:
|
|||||||
submodules: false
|
submodules: false
|
||||||
lfs: false
|
lfs: false
|
||||||
|
|
||||||
|
# 2️⃣ Python 설치
|
||||||
- name: Install Python
|
- name: Install Python
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
@@ -25,52 +31,63 @@ jobs:
|
|||||||
python3 --version
|
python3 --version
|
||||||
pip3 --version
|
pip3 --version
|
||||||
|
|
||||||
|
# 3️⃣ 의존성 설치
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip3 install --upgrade pip
|
pip3 install --upgrade pip
|
||||||
if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi
|
if [ -f requirements.txt ]; then
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4️⃣ 기본 테스트
|
||||||
- name: Run basic tests
|
- name: Run basic tests
|
||||||
run: |
|
run: |
|
||||||
echo "✅ 코드 체크아웃 성공"
|
echo "✅ 코드 체크아웃 성공"
|
||||||
echo "✅ 의존성 설치 성공"
|
echo "✅ Python 환경 준비 완료"
|
||||||
|
echo "✅ 의존성 설치 완료"
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Server
|
name: Deploy to Server
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
needs: test
|
needs: test
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy via SSH
|
- name: Deploy via SSH
|
||||||
run: |
|
run: |
|
||||||
# SSH 키 설정
|
set -e
|
||||||
|
|
||||||
|
echo "🔐 SSH 설정 중..."
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
ssh-keyscan -H 192.168.0.97 >> ~/.ssh/known_hosts
|
ssh-keyscan -H 192.168.0.97 >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
# 서버에 배포
|
echo "🚀 서버 배포 시작"
|
||||||
ssh kdesk84@192.168.0.97 << 'EOF'
|
ssh kdesk84@192.168.0.97 << 'EOF'
|
||||||
echo "=== VConnect API 배포 시작 ==="
|
set -e
|
||||||
|
|
||||||
|
echo "📂 프로젝트 디렉토리 이동"
|
||||||
cd /data/vconnect-api
|
cd /data/vconnect-api
|
||||||
|
|
||||||
# Git Pull
|
echo "📦 최신 코드 가져오기"
|
||||||
echo "📦 최신 코드 가져오기..."
|
|
||||||
git pull origin main
|
git pull origin main
|
||||||
|
|
||||||
# 가상환경에서 의존성 업데이트
|
echo "🐍 가상환경 활성화"
|
||||||
echo "📦 의존성 업데이트..."
|
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
|
|
||||||
|
echo "📦 의존성 업데이트"
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
# 서비스 재시작
|
echo "🔄 서비스 재시작"
|
||||||
echo "🔄 서비스 재시작..."
|
|
||||||
sudo systemctl restart vconnect-api
|
sudo systemctl restart vconnect-api
|
||||||
|
|
||||||
# 상태 확인
|
echo "📋 서비스 상태 확인"
|
||||||
echo "✅ 배포 완료! 서비스 상태:"
|
|
||||||
sudo systemctl status vconnect-api --no-pager -l
|
sudo systemctl status vconnect-api --no-pager -l
|
||||||
|
|
||||||
|
echo "✅ 배포 완료"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Deployment Complete
|
- name: Deployment Complete
|
||||||
run: echo "🎉 VConnect API 배포 완료!"
|
run: echo "🎉 VConnect API 배포 완료!"
|
||||||
|
|||||||
Reference in New Issue
Block a user