From 271c3f1f7d93332dab6d41c7d982ab4ce3a8f420 Mon Sep 17 00:00:00 2001 From: Yera All Date: Sat, 4 Apr 2026 03:02:59 +0500 Subject: [PATCH] Fallback source deploy to local production path --- .gitlab-ci.yml | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b9e344..486e617 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -200,28 +200,37 @@ deploy-production-source: environment: name: production before_script: - - command -v ssh >/dev/null - command -v rsync >/dev/null - command -v docker >/dev/null - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - printf '%s\n' "$DEPLOY_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 - - chmod 600 ~/.ssh/id_ed25519 - - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts + - | + if [ -n "$DEPLOY_HOST" ] && [ -n "$DEPLOY_USER" ]; then + command -v ssh >/dev/null + mkdir -p ~/.ssh + chmod 700 ~/.ssh + printf '%s\n' "$DEPLOY_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts + fi script: - - test -n "$DEPLOY_HOST" - - test -n "$DEPLOY_USER" - - test -n "$DEPLOY_PATH" - - ssh "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p '$DEPLOY_PATH'" - - rsync -av --exclude '.git/' --exclude '.tmp/' --exclude '.codex_tmp/' --exclude '.local_stack/' --exclude '.data_pg/' ./ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/" + - export DEPLOY_TARGET_PATH="${DEPLOY_PATH:-/home/mvpcc/call-center}" - | - ssh "$DEPLOY_USER@$DEPLOY_HOST" \ - "mkdir -p '$DEPLOY_PATH/.data_local/generated_ivr_yandex/ivr' '$DEPLOY_PATH/.data_local/recordings' '$DEPLOY_PATH/.asterisk_assets'" - - | - ssh "$DEPLOY_USER@$DEPLOY_HOST" \ - "cd '$DEPLOY_PATH/deployment' && \ - docker compose -f docker-compose.server.yml up -d --build && \ - docker compose -f docker-compose.asterisk.server.yml up -d --build" + if [ -n "$DEPLOY_HOST" ] && [ -n "$DEPLOY_USER" ]; then + ssh "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p '$DEPLOY_TARGET_PATH'" + rsync -av --exclude '.git/' --exclude '.tmp/' --exclude '.codex_tmp/' --exclude '.local_stack/' --exclude '.data_pg/' ./ "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_TARGET_PATH/" + ssh "$DEPLOY_USER@$DEPLOY_HOST" \ + "mkdir -p '$DEPLOY_TARGET_PATH/.data_local/generated_ivr_yandex/ivr' '$DEPLOY_TARGET_PATH/.data_local/recordings' '$DEPLOY_TARGET_PATH/.asterisk_assets'" + ssh "$DEPLOY_USER@$DEPLOY_HOST" \ + "cd '$DEPLOY_TARGET_PATH/deployment' && \ + docker compose -f docker-compose.server.yml up -d --build && \ + docker compose -f docker-compose.asterisk.server.yml up -d --build" + else + mkdir -p "$DEPLOY_TARGET_PATH" + rsync -av --exclude '.git/' --exclude '.tmp/' --exclude '.codex_tmp/' --exclude '.local_stack/' --exclude '.data_pg/' ./ "$DEPLOY_TARGET_PATH/" + mkdir -p "$DEPLOY_TARGET_PATH/.data_local/generated_ivr_yandex/ivr" "$DEPLOY_TARGET_PATH/.data_local/recordings" "$DEPLOY_TARGET_PATH/.asterisk_assets" + cd "$DEPLOY_TARGET_PATH/deployment" + docker compose -f docker-compose.server.yml up -d --build + docker compose -f docker-compose.asterisk.server.yml up -d --build + fi rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' when: manual