fix(web): preserve lazy chunks across releases
Deploy / Build Production Runtime Images (push) Successful in 8m56s
Deploy / Deploy Production (push) Successful in 56s
Deploy / Production Browser E2E (push) Successful in 32s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
Deploy / Deploy Staging (push) Has been skipped
Deploy / Build Production Runtime Images (push) Successful in 8m56s
Deploy / Deploy Production (push) Successful in 56s
Deploy / Production Browser E2E (push) Successful in 32s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
Deploy / Deploy Staging (push) Has been skipped
This commit is contained in:
@@ -180,10 +180,27 @@ jobs:
|
||||
test -f "$release_tar"
|
||||
test -f "/var/lib/xiaoxia-saas-production/runtime-images-${RELEASE_VERSION}.tar"
|
||||
mkdir -p /var/lib/xiaoxia-saas-production
|
||||
old_assets_dir="/tmp/xiaoxia-previous-web-assets-${RELEASE_VERSION}"
|
||||
rm -rf "$old_assets_dir"
|
||||
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
|
||||
mkdir -p /var/lib/xiaoxia-saas-production/repo
|
||||
tar -xzf "$release_tar" -C /var/lib/xiaoxia-saas-production/repo
|
||||
test -f /var/lib/xiaoxia-saas-production/repo/apps/web/dist/index.html
|
||||
if [ -d "$old_assets_dir" ]; then
|
||||
mkdir -p /var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets
|
||||
for asset in "$old_assets_dir"/*; do
|
||||
[ -e "$asset" ] || continue
|
||||
name="$(basename "$asset")"
|
||||
if [ ! -e "/var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets/$name" ]; then
|
||||
cp -a "$asset" "/var/lib/xiaoxia-saas-production/repo/apps/web/dist/assets/$name"
|
||||
fi
|
||||
done
|
||||
rm -rf "$old_assets_dir"
|
||||
fi
|
||||
test -f /var/lib/xiaoxia-saas-production/.env
|
||||
cp /var/lib/xiaoxia-saas-production/.env /var/lib/xiaoxia-saas-production/repo/.env
|
||||
HOST_PREFIX= sh /var/lib/xiaoxia-saas-production/repo/infra/docker/deploy-production.sh
|
||||
|
||||
@@ -21,8 +21,13 @@ server {
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
|
||||
@@ -54,6 +54,15 @@ def test_deploy_production_uses_production_infra_and_project():
|
||||
assert "EXPECTED_VERSION=$RELEASE_VERSION" in script
|
||||
|
||||
|
||||
def test_production_workflow_preserves_previous_web_assets():
|
||||
workflow = Path(".gitea/workflows/deploy.yml").read_text(encoding="utf-8")
|
||||
production_section = workflow.split("deploy-production:", 1)[1]
|
||||
|
||||
assert "old_assets_dir=\"/tmp/xiaoxia-previous-web-assets-${RELEASE_VERSION}\"" 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
|
||||
|
||||
|
||||
def test_production_deploy_recreates_web_after_api_for_nginx_dns():
|
||||
script = Path("infra/docker/deploy-production.sh").read_text(encoding="utf-8")
|
||||
|
||||
@@ -72,6 +81,8 @@ def test_production_nginx_static_upstream_requires_web_recreate():
|
||||
assert "client_max_body_size 800m;" in config
|
||||
assert "proxy_read_timeout 300s;" in config
|
||||
assert "proxy_request_buffering off;" in config
|
||||
assert 'location = /index.html' in config
|
||||
assert 'Cache-Control "no-store, no-cache, must-revalidate" always' in config
|
||||
assert "--force-recreate web" in script
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user