From 200ddda352c91c8740aff133d25110ced34a92c6 Mon Sep 17 00:00:00 2001 From: devops Date: Wed, 14 Oct 2026 20:56:33 +0000 Subject: [PATCH] fix(ci): preserve support chat runtime configuration --- .gitea/workflows/deploy.yml | 1 + scripts/compose.prod.yml | 3 +++ scripts/deploy.sh | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 13be216c..1c8c6e15 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -13,6 +13,7 @@ jobs: - name: Run deploy.sh from within the scripts folder env: BRANCH: ${{ github.ref_name }} + SUPPORT_CHAT_KEY: ${{ secrets.SUPPORT_CHAT_KEY }} run: | # 1. رفع مشکل DNS و غیرفعال کردن پروکسی برای دامنه محلی echo "87.248.133.138 git.parsaaghayi.ir" >> /etc/hosts diff --git a/scripts/compose.prod.yml b/scripts/compose.prod.yml index 70872104..3a370039 100644 --- a/scripts/compose.prod.yml +++ b/scripts/compose.prod.yml @@ -27,6 +27,9 @@ services: NPM_REGISTRY: ${NPM_REGISTRY:-} container_name: canino_backend_prod restart: always + env_file: + - path: .support-chat.env + required: false environment: - NODE_ENV=production - ENABLE_SWAGGER=false diff --git a/scripts/deploy.sh b/scripts/deploy.sh index a9a176b6..724875ae 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -66,6 +66,19 @@ fi cd "$TARGET_DIR" +# Inject support-chat runtime configuration from CI/CD without committing secrets. +if [ "${SUPPORT_CHAT_KEY+x}" = x ]; then + touch .support-chat.env + grep -v '^SUPPORT_CHAT_KEY=' .support-chat.env > .support-chat.env.tmp || true + printf "SUPPORT_CHAT_KEY=%s\n" "$SUPPORT_CHAT_KEY" >> .support-chat.env.tmp + mv .support-chat.env.tmp .support-chat.env + chmod 600 .support-chat.env +fi +if [ ! -s .support-chat.env ]; then + echo "ERROR: missing .support-chat.env / SUPPORT_CHAT_KEY; refusing deployment" >&2 + exit 1 +fi + # ✅ فایل‌های کانفیگ را از پوشه‌ی scripts مخزن به TARGET_DIR کپی می‌کنیم echo "Copying configuration files in $TARGET_DIR..." cp "scripts/$COMPOSE_FILE" "docker-compose.yml"