deploy
Some checks failed
Build & Deploy KLZ Cables / deploy (push) Failing after 3m49s

This commit is contained in:
2026-01-25 12:20:31 +01:00
parent b3827b95c2
commit aac2cb2041

View File

@@ -92,11 +92,25 @@ jobs:
run: |
echo "Starting deployment on server..."
# Create deployment script on server
# Create environment file for deployment
cat > /tmp/deploy.env << EOF
export REGISTRY_USER='${REGISTRY_USER}'
export REGISTRY_PASS='${REGISTRY_PASS}'
export NEXT_PUBLIC_UMAMI_WEBSITE_ID='${NEXT_PUBLIC_UMAMI_WEBSITE_ID}'
export NEXT_PUBLIC_UMAMI_SCRIPT_URL='${NEXT_PUBLIC_UMAMI_SCRIPT_URL}'
export SENTRY_DSN='${SENTRY_DSN}'
export REDIS_URL='${REDIS_URL}'
export REDIS_KEY_PREFIX='${REDIS_KEY_PREFIX}'
EOF
# Create deployment script
cat > /tmp/deploy.sh << 'DEPLOY_EOF'
#!/bin/bash
set -e
# Load environment variables
source /tmp/deploy.env
echo '=== Starting deployment ==='
cd /home/deploy/sites/klz-cables.com
@@ -110,13 +124,7 @@ jobs:
EOF
echo '=== Logging into Docker registry ==='
echo '${REGISTRY_PASS}' | docker login registry.infra.mintel.me -u '${REGISTRY_USER}' --password-stdin
if [ $? -eq 0 ]; then
echo '✓ Registry login successful'
else
echo '✗ Registry login failed'
exit 1
fi
echo "${REGISTRY_PASS}" | docker login registry.infra.mintel.me -u "${REGISTRY_USER}" --password-stdin
echo '=== Checking if infra network exists ==='
if ! docker network inspect infra >/dev/null 2>&1; then
@@ -127,34 +135,17 @@ jobs:
echo '=== Checking current containers ==='
docker compose ps
echo '=== Checking current image ==='
docker images registry.infra.mintel.me/mintel/klz-cables.com:latest
echo '=== Removing local image to force fresh pull ==='
docker rmi registry.infra.mintel.me/mintel/klz-cables.com:latest || true
echo '=== Pulling latest image ==='
docker compose pull
echo '✓ Image pull command completed'
echo '=== Verifying new image after pull ==='
docker images registry.infra.mintel.me/mintel/klz-cables.com:latest
echo '=== Checking if image was actually updated ==='
if docker inspect registry.infra.mintel.me/mintel/klz-cables.com:latest >/dev/null 2>&1; then
echo '✓ Image exists locally'
else
echo '✗ Image pull failed - image not found locally'
exit 1
fi
echo '=== Stopping all containers ==='
docker compose down
echo '✓ Containers stopped'
echo '=== Starting all containers ==='
docker compose up -d
echo '✓ Containers started'
echo '=== Waiting for containers to be ready (30 seconds) ==='
sleep 30
@@ -162,12 +153,6 @@ jobs:
echo '=== Verifying deployment status ==='
docker compose ps
echo '=== Checking app container logs ==='
docker compose logs --tail=30 app
echo '=== Checking varnish container logs ==='
docker compose logs --tail=20 varnish
echo '=== Verifying application health ==='
# Wait a bit more for the app to be fully ready
sleep 15
@@ -185,31 +170,40 @@ jobs:
echo '=== Deployment completed successfully ==='
DEPLOY_EOF
# Make script executable and copy to server
# Make script executable
chmod +x /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
# SSH options for reliability
SSH_OPTS="-i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=30 -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o BatchMode=yes"
# Copy files to server
scp $SSH_OPTS /tmp/deploy.sh /tmp/deploy.env deploy@alpha.mintel.me:/tmp/
# 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"
# Execute deployment script on server with retry mechanism
MAX_RETRIES=3
RETRY_COUNT=0
SUCCESS=false
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "Deployment attempt $RETRY_COUNT of $MAX_RETRIES..."
if ssh $SSH_OPTS deploy@alpha.mintel.me "bash /tmp/deploy.sh"; then
echo "✓ Deployment successful!"
SUCCESS=true
break
else
echo "✗ Deployment failed on attempt $i"
if [ $i -eq 3 ]; then
echo "All deployment attempts failed"
exit 1
echo "✗ Deployment attempt $RETRY_COUNT failed."
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
echo "Retrying in 10 seconds..."
sleep 10
fi
echo "Retrying in 10 seconds..."
sleep 10
fi
done
if [ "$SUCCESS" = false ]; then
echo "All deployment attempts failed."
exit 1
fi
echo "Deployment completed"