diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9cb5910a..f846c7da 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -188,13 +188,28 @@ jobs: # Make script executable and copy to server chmod +x /tmp/deploy.sh - # Copy deployment script to server - scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 /tmp/deploy.sh deploy@alpha.mintel.me:/tmp/deploy.sh + # Copy deployment script to server with keep-alive and timeout + scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o ConnectTimeout=30 /tmp/deploy.sh deploy@alpha.mintel.me:/tmp/deploy.sh - # Execute deployment script on server - ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me " - set -e - bash /tmp/deploy.sh - " + # Execute deployment script on server with keep-alive and timeout + # Retry up to 3 times if connection is lost + for i in {1..3}; do + echo "Attempt $i of 3..." + if ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o ConnectTimeout=30 -o ServerAliveTimeout=300 deploy@alpha.mintel.me " + set -e + bash /tmp/deploy.sh + "; then + echo "✓ Deployment successful on attempt $i" + break + else + echo "✗ Deployment failed on attempt $i" + if [ $i -eq 3 ]; then + echo "All deployment attempts failed" + exit 1 + fi + echo "Retrying in 10 seconds..." + sleep 10 + fi + done echo "Deployment completed" \ No newline at end of file