File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 BUILD_CONFIGURATION : ' Release'
1111
1212jobs :
13- build-and-deploy :
14- runs-on : self-hosted # 在 IIS 服务器本机运行
13+ # ========== Job 1: 在 GitHub 云端构建 ==========
14+ build :
15+ runs-on : windows-latest # 使用 GitHub 提供的快速云端 Runner
1516
1617 steps :
1718 - name : 检出代码
1819 uses : actions/checkout@v4
1920
20- # Self-hosted Runner 上已安装 .NET SDK,无需再次设置
21-
21+ - name : 设置 .NET SDK
22+ uses : actions/setup-dotnet@v4
23+ with :
24+ dotnet-version : ${{ env.DOTNET_VERSION }}
25+
2226 - name : 验证 .NET 版本
2327 run : |
2428 Write-Host "当前 .NET 版本:"
4347 Remove-Item -Path "./publish/manage/appsettings.json" -Force -ErrorAction SilentlyContinue
4448 Remove-Item -Path "./publish/manage/appsettings.Development.json" -Force -ErrorAction SilentlyContinue
4549 Write-Host "✅ 已移除 appsettings.json 文件,请在服务器上手动配置"
50+
51+ # 上传构建产物供部署 job 使用
52+ - name : 上传 Client 构建产物
53+ uses : actions/upload-artifact@v4
54+ with :
55+ name : client-build
56+ path : ./publish/client
57+ retention-days : 1 # 只保留1天,节省存储空间
58+
59+ - name : 上传 Manage 构建产物
60+ uses : actions/upload-artifact@v4
61+ with :
62+ name : manage-build
63+ path : ./publish/manage
64+ retention-days : 1
65+
66+ # ========== Job 2: 在你的服务器上部署 ==========
67+ deploy :
68+ needs : build # 等待构建 job 完成
69+ runs-on : self-hosted # 在你的 IIS 服务器本机运行
70+
71+ steps :
72+ # 下载构建产物(比完整代码库小很多)
73+ - name : 下载 Client 构建产物
74+ uses : actions/download-artifact@v4
75+ with :
76+ name : client-build
77+ path : ./publish/client
78+
79+ - name : 下载 Manage 构建产物
80+ uses : actions/download-artifact@v4
81+ with :
82+ name : manage-build
83+ path : ./publish/manage
4684
4785 - name : 部署到本机 IIS
4886 shell : pwsh
You can’t perform that action at this time.
0 commit comments