This commit is contained in:
@@ -94,9 +94,15 @@ jobs:
|
||||
set -e
|
||||
|
||||
# Load environment variables
|
||||
source ./deploy.env
|
||||
if [ -f ./deploy.env ]; then
|
||||
source ./deploy.env
|
||||
else
|
||||
echo "ERROR: deploy.env not found in $(pwd)"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '=== Starting deployment ==='
|
||||
echo "=== Starting deployment at $(date) ==="
|
||||
|
||||
echo '=== Creating .env ==='
|
||||
cat > .env << EOF
|
||||
@@ -108,7 +114,10 @@ jobs:
|
||||
EOF
|
||||
|
||||
echo '=== Logging into Docker registry ==='
|
||||
echo "${REGISTRY_PASS}" | docker login registry.infra.mintel.me -u "${REGISTRY_USER}" --password-stdin
|
||||
if ! echo "${REGISTRY_PASS}" | docker login registry.infra.mintel.me -u "${REGISTRY_USER}" --password-stdin; then
|
||||
echo "ERROR: Docker login failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '=== Checking if infra network exists ==='
|
||||
if ! docker network inspect infra >/dev/null 2>&1; then
|
||||
@@ -118,12 +127,32 @@ jobs:
|
||||
|
||||
echo '=== Pulling latest image ==='
|
||||
# Explicitly pull the image to ensure we get the latest version
|
||||
docker pull registry.infra.mintel.me/mintel/klz-cables.com:latest
|
||||
docker compose pull
|
||||
echo "Pulling registry.infra.mintel.me/mintel/klz-cables.com:latest..."
|
||||
if ! docker pull registry.infra.mintel.me/mintel/klz-cables.com:latest; then
|
||||
echo "ERROR: docker pull failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we should use 'docker compose' or 'docker-compose'
|
||||
COMPOSE_CMD="docker compose"
|
||||
if ! $COMPOSE_CMD version >/dev/null 2>&1; then
|
||||
COMPOSE_CMD="docker-compose"
|
||||
fi
|
||||
echo "Using compose command: $COMPOSE_CMD"
|
||||
|
||||
echo "Pulling via compose..."
|
||||
$COMPOSE_CMD pull
|
||||
|
||||
echo '=== Restarting containers ==='
|
||||
# Use --force-recreate to ensure containers are updated even if compose thinks they are up to date
|
||||
docker compose up -d --force-recreate --remove-orphans
|
||||
echo "Running $COMPOSE_CMD up..."
|
||||
if ! $COMPOSE_CMD up -d --force-recreate --remove-orphans; then
|
||||
echo "ERROR: docker compose up failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '=== Verifying images ==='
|
||||
docker images registry.infra.mintel.me/mintel/klz-cables.com:latest
|
||||
|
||||
echo '=== Waiting for containers (30s) ==='
|
||||
sleep 30
|
||||
@@ -148,8 +177,14 @@ jobs:
|
||||
# Use a single SSH connection to sync and execute
|
||||
# We use tar to bundle everything and pipe it to SSH
|
||||
# We use the same SSH options that worked in the previous Sync step
|
||||
# Added -v to ssh for more debug info if it fails
|
||||
# Added set -x to the remote command to see exactly what's happening
|
||||
tar czf - -C /tmp/klz-deploy . | \
|
||||
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/ && cd /home/deploy/sites/klz-cables.com/ && bash ./deploy.sh"
|
||||
"set -x; mkdir -p /home/deploy/sites/klz-cables.com/ && tar xzf - -C /home/deploy/sites/klz-cables.com/ && cd /home/deploy/sites/klz-cables.com/ && ls -la && bash -x ./deploy.sh"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Remote deployment failed!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Deployment process finished"
|
||||
Reference in New Issue
Block a user