Files
factoryOps-v2/.gitea/workflows/deploy.yml
Johngreen 741c868367
All checks were successful
Deploy to Production / deploy (push) Successful in 59s
fix(ci): stop v1 containers before starting v2 to free ports 8100/4000
2026-02-10 12:33:20 +09:00

48 lines
1.6 KiB
YAML

name: Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Install tools
run: |
rm -f /etc/apt/sources.list.d/github_git-lfs.list || true
apt-get update && apt-get install -y openssh-client rsync git
- name: Checkout code
run: |
git clone https://geonhee:${{ secrets.DEPLOY_TOKEN }}@g.wace.me/geonhee/factoryOps-v2.git /tmp/factoryOps-v2
cd /tmp/factoryOps-v2 && git checkout main
- name: Deploy to server
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
rsync -avz --delete \
--exclude '.git' \
--exclude 'node_modules' \
--exclude '__pycache__' \
--exclude '.venv' \
--exclude '.env' \
--exclude '.next' \
--exclude 'planning' \
-e "ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key" \
/tmp/factoryOps-v2/ geonhee@192.168.1.200:~/factoryops-v2/
ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key geonhee@192.168.1.200 << 'ENDSSH'
cd ~/factoryops && ~/.local/bin/docker-compose -f docker-compose.prod.yml down 2>/dev/null || true
cd ~/factoryops-v2
~/.local/bin/docker-compose -f docker-compose.prod.yml up -d --build --force-recreate
echo "FactoryOps v2 deployed at $(date)"
ENDSSH
rm -f ~/.ssh/deploy_key