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

This commit is contained in:
2026-01-25 11:28:23 +01:00
parent c2d6e082e8
commit 3288bbd745

View File

@@ -63,8 +63,18 @@ jobs:
echo "Found and syncing: $COMPOSE_FILE" echo "Found and syncing: $COMPOSE_FILE"
# Create a temporary directory for files to sync
mkdir -p /tmp/klz-deploy
cp "$COMPOSE_FILE" /tmp/klz-deploy/
# Check if varnish directory exists and copy it
if [ -d "varnish" ]; then
echo "Syncing varnish directory..."
cp -r varnish /tmp/klz-deploy/
fi
# Use tar to bundle files and send them via SSH in a single connection # Use tar to bundle files and send them via SSH in a single connection
tar czf - "$COMPOSE_FILE" varnish 2>/dev/null || tar czf - "$COMPOSE_FILE" | \ tar czf - -C /tmp/klz-deploy . | \
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me \ ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me \
"mkdir -p /home/deploy/sites/klz-cables.com/ && tar xzf - -C /home/deploy/sites/klz-cables.com/ && echo 'Files synced successfully' && ls -la /home/deploy/sites/klz-cables.com/" "mkdir -p /home/deploy/sites/klz-cables.com/ && tar xzf - -C /home/deploy/sites/klz-cables.com/ && echo 'Files synced successfully' && ls -la /home/deploy/sites/klz-cables.com/"
@@ -74,21 +84,33 @@ jobs:
env: env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASS: ${{ secrets.REGISTRY_PASS }} REGISTRY_PASS: ${{ secrets.REGISTRY_PASS }}
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
NEXT_PUBLIC_UMAMI_SCRIPT_URL: ${{ secrets.NEXT_PUBLIC_UMAMI_SCRIPT_URL }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
REDIS_URL: ${{ secrets.REDIS_URL }}
REDIS_KEY_PREFIX: ${{ secrets.REDIS_KEY_PREFIX }}
run: | run: |
echo "Starting deployment on server..." echo "Starting deployment on server..."
# Execute deployment commands directly with proper error handling # Create deployment script on server
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me " cat > /tmp/deploy.sh << 'DEPLOY_EOF'
#!/bin/bash
set -e set -e
echo '=== Starting deployment ===' echo '=== Starting deployment ==='
cd /home/deploy/sites/klz-cables.com cd /home/deploy/sites/klz-cables.com
echo '=== Creating .env ===' echo '=== Creating .env ==='
echo 'SENTRY_DSN=${{ secrets.SENTRY_DSN }}' > .env cat > .env << EOF
NEXT_PUBLIC_UMAMI_WEBSITE_ID=${NEXT_PUBLIC_UMAMI_WEBSITE_ID}
NEXT_PUBLIC_UMAMI_SCRIPT_URL=${NEXT_PUBLIC_UMAMI_SCRIPT_URL}
SENTRY_DSN=${SENTRY_DSN}
REDIS_URL=${REDIS_URL}
REDIS_KEY_PREFIX=${REDIS_KEY_PREFIX}
EOF
echo '=== Logging into Docker registry ===' echo '=== Logging into Docker registry ==='
echo '${{ secrets.REGISTRY_PASS }}' | docker login registry.infra.mintel.me -u '${{ secrets.REGISTRY_USER }}' --password-stdin echo '${REGISTRY_PASS}' | docker login registry.infra.mintel.me -u '${REGISTRY_USER}' --password-stdin
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo '✓ Registry login successful' echo '✓ Registry login successful'
else else
@@ -96,6 +118,12 @@ jobs:
exit 1 exit 1
fi fi
echo '=== Checking if infra network exists ==='
if ! docker network inspect infra >/dev/null 2>&1; then
echo 'Creating infra network...'
docker network create infra || true
fi
echo '=== Checking current containers ===' echo '=== Checking current containers ==='
docker compose ps docker compose ps
@@ -128,8 +156,8 @@ jobs:
docker compose up -d docker compose up -d
echo '✓ Containers started' echo '✓ Containers started'
echo '=== Waiting for containers to be ready (20 seconds) ===' echo '=== Waiting for containers to be ready (30 seconds) ==='
sleep 20 sleep 30
echo '=== Verifying deployment status ===' echo '=== Verifying deployment status ==='
docker compose ps docker compose ps
@@ -142,7 +170,7 @@ jobs:
echo '=== Verifying application health ===' echo '=== Verifying application health ==='
# Wait a bit more for the app to be fully ready # Wait a bit more for the app to be fully ready
sleep 10 sleep 15
if curl -f -s http://localhost:80/health > /dev/null 2>&1; then if curl -f -s http://localhost:80/health > /dev/null 2>&1; then
echo '✓ Application health check passed' echo '✓ Application health check passed'
else else
@@ -155,6 +183,18 @@ jobs:
docker image prune -f --filter 'until=24h' docker image prune -f --filter 'until=24h'
echo '=== Deployment completed successfully ===' echo '=== Deployment completed successfully ==='
DEPLOY_EOF
# 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
# 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
" "
echo "Deployment completed" echo "Deployment completed"