Skip to content

Commit 6836f8a

Browse files
v-weimin@handshakes.com.sgv-weimin@handshakes.com.sg
authored andcommitted
优化变更检测逻辑,确保获取完整历史以正确比较变更,并增强输出信息,增加无变更时的提示
1 parent 947e13b commit 6836f8a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/deploy-to-iis-local.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
steps:
2222
- name: 检出代码
2323
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # 获取完整历史,确保能正确比较变更
2426

2527
- name: 检测文件变更
2628
uses: dorny/paths-filter@v3
@@ -38,10 +40,12 @@ jobs:
3840
- 'AI.DeliciousFood.Core.Model/**'
3941
- 'AI.DeliciousFood.Core.Data/**'
4042
- '*.sln'
43+
base: ${{ github.event.before }}
4144

4245
# ========== Job 1: 在 GitHub 云端构建 ==========
4346
build:
4447
needs: detect-changes
48+
if: needs.detect-changes.outputs.client-changed == 'true' || needs.detect-changes.outputs.manage-changed == 'true' || needs.detect-changes.outputs.common-changed == 'true'
4549
runs-on: windows-latest # 使用 GitHub 提供的快速云端 Runner
4650

4751
steps:
@@ -63,10 +67,18 @@ jobs:
6367

6468
- name: 显示变更检测结果
6569
run: |
66-
Write-Host "变更检测结果:"
70+
Write-Host "========== 变更检测结果 =========="
6771
Write-Host "Client 变更: ${{ needs.detect-changes.outputs.client-changed }}"
6872
Write-Host "Manage 变更: ${{ needs.detect-changes.outputs.manage-changed }}"
6973
Write-Host "Common 变更: ${{ needs.detect-changes.outputs.common-changed }}"
74+
Write-Host "=================================="
75+
76+
if ("${{ needs.detect-changes.outputs.client-changed }}" -ne "true" -and
77+
"${{ needs.detect-changes.outputs.manage-changed }}" -ne "true" -and
78+
"${{ needs.detect-changes.outputs.common-changed }}" -ne "true") {
79+
Write-Host "⚠️ 没有检测到任何项目代码变更,可能只是修改了配置文件或文档"
80+
Write-Host "跳过构建步骤..."
81+
}
7082
7183
- name: 构建解决方案
7284
run: dotnet build AI.DeliciousFood.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
@@ -127,6 +139,7 @@ jobs:
127139
# ========== Job 2: 在你的服务器上部署 ==========
128140
deploy:
129141
needs: [build, detect-changes] # 等待构建 job 完成,同时获取变更检测结果
142+
if: needs.detect-changes.outputs.client-changed == 'true' || needs.detect-changes.outputs.manage-changed == 'true' || needs.detect-changes.outputs.common-changed == 'true'
130143
runs-on: self-hosted # 在你的 IIS 服务器本机运行
131144
env:
132145
NODE_OPTIONS: --max-old-space-size=1024 # 限制为 1GB,避免占用过多内存

0 commit comments

Comments
 (0)