Fallback source deploy to local production path

This commit is contained in:
Yera All
2026-04-04 03:02:59 +05:00
parent a7033a8dc3
commit 271c3f1f7d
+27 -18
View File
@@ -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