diff --git a/.gitea/workflows/ci-pipeline.yml b/.gitea/workflows/ci-pipeline.yml index af573815b..8105fad5f 100755 --- a/.gitea/workflows/ci-pipeline.yml +++ b/.gitea/workflows/ci-pipeline.yml @@ -1288,6 +1288,14 @@ jobs: "${staging_user}@${staging_host}:/var/lib/xiaoxia-saas-staging/.env" echo "✅ .env uploaded to staging server" + # 上传抖音 cookies 文件到 staging host(供容器挂载) + echo "Uploading Douyin cookies to staging server..." + ssh -p "$staging_port" -i "$key_path" -o StrictHostKeyChecking=no "${staging_user}@${staging_host}" \ + "mkdir -p /var/lib/xiaoxia-saas-staging/configs" + scp -P "$staging_port" -i "$key_path" -o StrictHostKeyChecking=no deploy/configs/douyin_cookies.txt \ + "${staging_user}@${staging_host}:/var/lib/xiaoxia-saas-staging/configs/douyin_cookies.txt" + echo "✅ Douyin cookies uploaded" + # 通过环境变量传递凭证,避免命令行引号转义问题 cat scripts/ci_staging_deploy.sh | ssh -p "$staging_port" -i "$key_path" -o StrictHostKeyChecking=no "${staging_user}@${staging_host}" "IMAGE_TAG=${GITHUB_SHA} ACR_USERNAME=${ACR_USERNAME} ACR_PASSWORD=${ACR_PASSWORD} sh" diff --git a/scripts/ci_staging_deploy.sh b/scripts/ci_staging_deploy.sh index 65022f0c3..7a704e822 100755 --- a/scripts/ci_staging_deploy.sh +++ b/scripts/ci_staging_deploy.sh @@ -67,18 +67,12 @@ echo "✅ .env file found: $ENV_FILE ($(wc -l < "$ENV_FILE") lines)" mkdir -p "$GENERATED_DIR" mkdir -p "$LEGACY_ASSETS_DIR" mkdir -p "$(dirname "$COOKIES_FILE")" -# 抖音 cookies 文件:优先使用 host 上已有的(>200B 视为真实),否则从 repo 拷贝 -# 镜像中已 baked-in 默认 cookies,但 host 挂载可在不重建镜像的情况下更新 -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_COOKIES="$(dirname "$SCRIPT_DIR")/deploy/configs/douyin_cookies.txt" +# 抖音 cookies 文件:CI workflow 已通过 scp 上传;如果不存在(非 CI 环境)则创建占位 if [ ! -f "$COOKIES_FILE" ] || [ "$(wc -c < "$COOKIES_FILE" 2>/dev/null || echo 0)" -lt 200 ]; then - if [ -f "$REPO_COOKIES" ] && [ "$(wc -c < "$REPO_COOKIES" 2>/dev/null || echo 0)" -gt 200 ]; then - cp "$REPO_COOKIES" "$COOKIES_FILE" - echo "Copied Douyin cookies from repo to $COOKIES_FILE ($(wc -c < "$COOKIES_FILE") bytes)" - else - printf '# Netscape HTTP Cookie File\n# 抖音 cookies 占位,请从浏览器导出并替换此文件\n' > "$COOKIES_FILE" - echo "Created empty cookies placeholder at $COOKIES_FILE (Douyin extraction will 503)" - fi + printf '# Netscape HTTP Cookie File\n# 抖音 cookies 占位(CI 应通过 scp 上传真实 cookies)\n' > "$COOKIES_FILE" + echo "WARNING: Douyin cookies not found or too small at $COOKIES_FILE (extraction will 503)" +else + echo "Douyin cookies ready: $COOKIES_FILE ($(wc -c < "$COOKIES_FILE") bytes)" fi # ── 写入 Staging Nginx 配置 ──