diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..ef619ca --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,75 @@ +name: Deploy CV Server + +on: + push: + branches: + - main + +jobs: + deploy: + name: Pull and Restart + runs-on: ubuntu-latest + + steps: + - name: Deploy to VPS + run: | + ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa txeo@172.233.115.81 << 'DEPLOY' + set -e + + echo "๐Ÿš€ Deploying cv-site..." + cd /home/txeo/Git/yo/cv + + echo "๐Ÿ”ง Fixing permissions..." + sudo chown -R $USER:$USER . + + if ! git diff-files --quiet || ! git diff-index --quiet --cached HEAD; then + echo "๐Ÿ’พ Stashing local changes..." + git stash push -m "Auto-stash $(date +%Y%m%d-%H%M%S)" + fi + + echo "๐Ÿงน Cleaning..." + git clean -fd + + echo "๐Ÿ“ฅ Pulling..." + git remote set-url origin https://repos.txeo.club/txeo/cv-site.git + git pull origin main + + echo "๐ŸŽจ Building CSS..." + if command -v lightningcss &> /dev/null; then + mkdir -p static/dist + lightningcss --bundle --minify static/css/main.css -o static/dist/bundle.min.css + echo "โœ… CSS bundle created" + fi + + echo "๐Ÿ“‹ Updating systemd..." + sudo cp config/systemd/cv.service /etc/systemd/system/cv.service + sudo systemctl daemon-reload + + echo "๐Ÿ”„ Restarting..." + sudo systemctl stop cv || true + for i in $(seq 1 15); do + if ! sudo fuser 1999/tcp >/dev/null 2>&1; then break; fi + [ $i -eq 15 ] && sudo fuser -k 1999/tcp 2>/dev/null || true + sleep 1 + done + sudo systemctl start cv + sleep 3 + + if sudo systemctl is-active --quiet cv; then + echo "โœ… Service running" + else + echo "โŒ Service failed" + sudo journalctl -u cv -n 20 --no-pager + exit 1 + fi + DEPLOY + + - name: Health check + run: | + sleep 2 + if curl -sf http://172.233.115.81:1999/health > /dev/null 2>&1; then + echo "โœ… Health check passed" + else + echo "โŒ Health check failed" + exit 1 + fi