發布
Some checks failed
Backend_develop / build (push) Failing after 10s

This commit is contained in:
威勝 張 2025-02-24 21:02:55 +08:00
parent 272a3328be
commit a88862d6b0

View File

@ -14,53 +14,74 @@ jobs:
shell: powershell shell: powershell
run: | run: |
echo "Git clone_start" echo "Git clone_start"
cd D:\Code\Project\TCM
if (Test-Path "Backend") { Remove-Item -Recurse -Force "Backend" } # 刪除原資料 # 設定變數
if (-not (Test-Path "Backend")) {New-Item -Path "Backend" -ItemType Directory -Force} # 建立資料夾 $projectPath = "D:\Code\Project\TCM"
echo " Cloneing ..." $backendPath = "$projectPath\Backend"
git clone -b develop http://leovip125.ddns.net:8418/TCM/Backend.git $apiPath = "D:\Code\Server\TCM\API"
# 確保主資料夾存在
if (-not (Test-Path $projectPath)) {
echo "錯誤: 主資料夾 $projectPath 不存在"
exit 1
}
cd $projectPath
# 刪除原 Backend 資料夾
if (Test-Path $backendPath) {
Remove-Item -Recurse -Force $backendPath
}
# 確保目標資料夾存在
New-Item -Path $backendPath -ItemType Directory -Force | Out-Null
echo " Cloning repository..."
git clone -b develop http://leovip125.ddns.net:8418/TCM/Backend.git $backendPath
if ($LASTEXITCODE -ne 0) {
echo "錯誤: Git Clone 失敗"
exit 1
}
echo "Clone End" echo "Clone End"
# NET 發布
# .NET 發布
echo "發布 start" echo "發布 start"
# 切換到 Backend 目錄並確保存在 # 切換到 Backend 目錄
$backendPath = "D:\Code\Project\TCM\Backend" cd $backendPath
if (Test-Path $backendPath) { if ($LASTEXITCODE -ne 0) {
cd $backendPath echo "錯誤: 無法切換到 Backend 目錄"
} else { exit 1
echo "錯誤: Backend 目錄不存在" }
exit 1
}
# 還原與建置 # 還原與建置
dotnet restore dotnet restore
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet restore 失敗" echo "錯誤: dotnet restore 失敗"
exit 1 exit 1
} }
dotnet build --configuration Release dotnet build --configuration Release
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet build 失敗" echo "錯誤: dotnet build 失敗"
exit 1 exit 1
} }
# 移除舊的 API 發布資料夾 # 移除舊的 API 發布資料夾
$apiPath = "D:\Code\Server\TCM\API" if (Test-Path $apiPath) {
if (Test-Path $apiPath) { Remove-Item -Recurse -Force $apiPath
Remove-Item -Recurse -Force $apiPath }
}
# 確保目標資料夾存在 # 確保目標資料夾存在
New-Item -Path $apiPath -ItemType Directory -Force | Out-Null New-Item -Path $apiPath -ItemType Directory -Force | Out-Null
# 發布 # 發布
dotnet publish -c Release -o $apiPath dotnet publish -c Release -o $apiPath
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet publish 失敗" echo "錯誤: dotnet publish 失敗"
exit 1 exit 1
} }
echo "發布 end" echo "發布 end"