oleg.vodyanov91@gmail.com 8567a045d9 update pipeline
2026-01-27 00:20:41 +04:00

40 lines
1.1 KiB
Plaintext

pipeline {
agent { label 'docker' }
stages {
stage('Checkout'){
steps { checkout scm }
}
stage('Deploy Prod'){
steps {
sshagent (credentials: ['myinstalink-server']) {
sh '''
ssh -o StrictHostKeyChecking=no kreamond@109.73.204.66 '
set -euo pipefail
cd ~/docbot || exit 1
git diff --name-only origin/main main | grep -i 'alembic/versions' > db_script.txt || true
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
git checkout main
fi
if git pull origin main | grep -q "Already up to date."; then
echo "No updates to deploy."
exit 0
fi
git pull origin main
. .venv/bin/activate
if [ -s db_script.txt ]; then
echo "Database migration scripts detected. Running migrations..."
alembic upgrade head
else
echo "No database migration scripts detected."
fi
sudo ./new_version.sh
'
'''
}
}
}
}
}