ci: add Gitea Actions deploy workflow
Deploy CV Server / Pull and Restart (push) Failing after 1m32s
Deploy CV Server / Pull and Restart (push) Failing after 1m32s
Self-hosted CI/CD via act_runner on Mac Mini. Deploys to VPS via SSH on push to main.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user