From 72efc7cedbb30a6b72af0768eb1af9b50f9d2a7e Mon Sep 17 00:00:00 2001 From: Xiaoxia AI Date: Tue, 23 Jun 2026 18:48:13 +0800 Subject: [PATCH] fix(deploy): retain current web assets before release --- .gitea/workflows/deploy.yml | 5 ++++- tests/unit/test_release_scripts.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index fc5d5387a..3c94b478e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -182,8 +182,11 @@ jobs: mkdir -p /var/lib/xiaoxia-saas-production old_assets_dir="/tmp/xiaoxia-previous-web-assets-${RELEASE_VERSION}" rm -rf "$old_assets_dir" + mkdir -p "$old_assets_dir" + if docker inspect xiaoxia-web-production >/dev/null 2>&1; then + docker cp xiaoxia-web-production:/usr/share/nginx/html/assets/. "$old_assets_dir"/ 2>/dev/null || true + fi if [ -d /var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets ]; then - mkdir -p "$old_assets_dir" cp -a /var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets/. "$old_assets_dir"/ fi rm -rf /var/lib/xiaoxia-saas-production/repo diff --git a/tests/unit/test_release_scripts.py b/tests/unit/test_release_scripts.py index 5b742eb6a..aa5bb06ad 100644 --- a/tests/unit/test_release_scripts.py +++ b/tests/unit/test_release_scripts.py @@ -59,6 +59,7 @@ def test_production_workflow_preserves_previous_web_assets(): production_section = workflow.split("deploy-production:", 1)[1] assert "old_assets_dir=\"/tmp/xiaoxia-previous-web-assets-${RELEASE_VERSION}\"" in production_section + assert "docker cp xiaoxia-web-production:/usr/share/nginx/html/assets/. \"$old_assets_dir\"/" in production_section assert "cp -a /var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets/. \"$old_assets_dir\"/" in production_section assert "if [ ! -e \"/var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets/$name\" ]; then" in production_section