發布
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
run: |
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} # 建立資料夾
echo " Cloneing ..."
git clone -b develop http://leovip125.ddns.net:8418/TCM/Backend.git
# 設定變數
$projectPath = "D:\Code\Project\TCM"
$backendPath = "$projectPath\Backend"
$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"
# NET 發布
# .NET 發布
echo "發布 start"
# 切換到 Backend 目錄並確保存在
$backendPath = "D:\Code\Project\TCM\Backend"
if (Test-Path $backendPath) {
cd $backendPath
} else {
echo "錯誤: Backend 目錄不存在"
exit 1
}
# 切換到 Backend 目錄
cd $backendPath
if ($LASTEXITCODE -ne 0) {
echo "錯誤: 無法切換到 Backend 目錄"
exit 1
}
# 還原與建置
dotnet restore
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet restore 失敗"
exit 1
}
# 還原與建置
dotnet restore
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet restore 失敗"
exit 1
}
dotnet build --configuration Release
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet build 失敗"
exit 1
}
dotnet build --configuration Release
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet build 失敗"
exit 1
}
# 移除舊的 API 發布資料夾
$apiPath = "D:\Code\Server\TCM\API"
if (Test-Path $apiPath) {
Remove-Item -Recurse -Force $apiPath
}
# 移除舊的 API 發布資料夾
if (Test-Path $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
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet publish 失敗"
exit 1
}
# 發布
dotnet publish -c Release -o $apiPath
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet publish 失敗"
exit 1
}
echo "發布 end"
echo "發布 end"