From 3c206a831e9a0c6e7f074e0784741ed23d22887d Mon Sep 17 00:00:00 2001 From: lzh Date: Tue, 23 Dec 2025 13:53:31 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=BC=BA=E5=88=B6=E6=8F=90=E4=BA=A4di?= =?UTF-8?q?st=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy/README.md | 20 ++++++++++++-------- scripts/deploy/build-and-push.ps1 | 12 ++++++++++-- scripts/deploy/build-and-push.sh | 3 ++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/scripts/deploy/README.md b/scripts/deploy/README.md index cf0bc749a..80e41ba19 100644 --- a/scripts/deploy/README.md +++ b/scripts/deploy/README.md @@ -114,22 +114,26 @@ git push origin master ### 1. 构建产物必须提交到 Git -**必须确保** `apps/web-antd/dist` 目录被 Git 跟踪,否则 CI/CD 无法检测到变化。 +**重要**:`apps/web-antd/dist` 目录在 `.gitignore` 中被忽略,但我们需要将其提交到 Git 才能触发 CI/CD。 + +**脚本会自动处理**: +- 构建脚本(`build-and-push.sh` 和 `build-and-push.ps1`)会自动使用 `git add -f` 强制添加 dist 目录 +- 你不需要手动修改 `.gitignore` 文件 + +**手动添加方法**(如果使用脚本): +```bash +# 强制添加被忽略的 dist 目录 +git add -f apps/web-antd/dist +``` **检查方法**: ```bash # 检查 dist 是否被 Git 跟踪 git ls-files apps/web-antd/dist -# 如果输出为空,说明 dist 未被跟踪 +# 如果输出为空,说明 dist 未被跟踪,需要使用 -f 强制添加 ``` -**解决方法**: -- 如果 `dist` 在 `.gitignore` 中,需要临时移除或使用强制添加: - ```bash - git add -f apps/web-antd/dist - ``` - ### 2. 修改源码后必须重新构建 **重要**:修改源码后,CI/CD **不会自动触发**,需要: diff --git a/scripts/deploy/build-and-push.ps1 b/scripts/deploy/build-and-push.ps1 index a119f8c45..85fc02ba5 100644 --- a/scripts/deploy/build-and-push.ps1 +++ b/scripts/deploy/build-and-push.ps1 @@ -28,7 +28,14 @@ Write-Host "🔨 Building project..." -ForegroundColor Yellow pnpm build:antd # 5. 检查构建结果 -if (-not (Test-Path "apps\web-antd\dist") -or ((Get-ChildItem "apps\web-antd\dist" -ErrorAction SilentlyContinue).Count -eq 0)) { +$distPath = "apps\web-antd\dist" +if (-not (Test-Path $distPath)) { + Write-Host "❌ Error: Build failed, dist directory not found" -ForegroundColor Red + exit 1 +} + +$distItems = Get-ChildItem $distPath -ErrorAction SilentlyContinue +if ($null -eq $distItems -or $distItems.Count -eq 0) { Write-Host "❌ Error: Build failed, dist directory is empty" -ForegroundColor Red exit 1 } @@ -46,7 +53,8 @@ if ($response -eq "y" -or $response -eq "Y") { $gitStatus = git status --porcelain if ($gitStatus) { Write-Host "📝 Staging build artifacts..." -ForegroundColor Yellow - git add apps/web-antd/dist + # 使用 -f 强制添加被 .gitignore 忽略的 dist 目录 + git add -f apps/web-antd/dist git add -A # 添加其他更改 Write-Host "💾 Committing changes..." -ForegroundColor Yellow diff --git a/scripts/deploy/build-and-push.sh b/scripts/deploy/build-and-push.sh index fa801dead..82b3f4aee 100644 --- a/scripts/deploy/build-and-push.sh +++ b/scripts/deploy/build-and-push.sh @@ -46,7 +46,8 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then # 检查是否有未提交的更改 if [ -n "$(git status --porcelain)" ]; then echo "📝 Staging build artifacts..." - git add apps/web-antd/dist + # 使用 -f 强制添加被 .gitignore 忽略的 dist 目录 + git add -f apps/web-antd/dist git add -A # 添加其他更改 echo "💾 Committing changes..."