From a0ce37708e83415852921319bd034bec51f3d03a Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Thu, 5 Feb 2026 19:25:53 +0100 Subject: [PATCH] fix(ci): fix shell compatibility and scp order in deployment workflow --- .gitea/workflows/deploy.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c532a1a1..946c8d53 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -322,6 +322,7 @@ jobs: fetch-depth: 1 - name: ๐Ÿš€ Deploy to ${{ env.TARGET }} + shell: bash run: | echo "Deploying $TARGET โ†’ $IMAGE_TAG" @@ -368,6 +369,19 @@ jobs: AUTH_MIDDLEWARE=$( [[ "$TARGET" == "production" ]] && echo "compress" || echo "${PROJECT_NAME}-auth,compress" ) EOF + # 1. Cleanup and Create Directories on server BEFORE SCP + ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me bash << 'EOF' + set -e + mkdir -p /home/deploy/sites/klz-cables.com/varnish + mkdir -p /home/deploy/sites/klz-cables.com/directus/uploads /home/deploy/sites/klz-cables.com/directus/extensions + if [ -d "/home/deploy/sites/klz-cables.com/varnish/default.vcl" ]; then + echo "๐Ÿงน Removing directory 'varnish/default.vcl' created by Docker..." + rm -rf /home/deploy/sites/klz-cables.com/varnish/default.vcl + fi + chown -R deploy:deploy /home/deploy/sites/klz-cables.com/directus /home/deploy/sites/klz-cables.com/varnish + EOF + + # 2. Transfer files scp -o StrictHostKeyChecking=accept-new /tmp/klz-cables.env root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/$ENV_FILE scp -o StrictHostKeyChecking=accept-new docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/docker-compose.yml scp -r -o StrictHostKeyChecking=accept-new varnish root@alpha.mintel.me:/home/deploy/sites/klz-cables.com/ @@ -378,16 +392,6 @@ jobs: chmod 600 "$ENV_FILE" chown deploy:deploy "$ENV_FILE" - # Ensure standard directories exist and have correct permissions - mkdir -p directus/uploads directus/extensions - chown -R deploy:deploy varnish directus - - # Cleanup if Docker created a directory instead of mounting a file - if [ -d "varnish/default.vcl" ]; then - echo "๐Ÿงน Removing directory 'varnish/default.vcl' created by Docker..." - rm -rf varnish/default.vcl - fi - echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin echo "โ†’ Pulling image: $IMAGE_TAG" docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull