Backend/.gitea/workflows/develop.yml

67 lines
1.9 KiB
YAML
Raw Normal View History

2025-02-24 20:27:01 +08:00
name: Backend_develop # 工作流的名称
2025-02-24 20:42:35 +08:00
# 当有代码推送到仓库的 develop 分支时,这个 Actions 工作流会被触发并执行
2025-02-24 20:27:01 +08:00
on:
push:
branches:
- develop
jobs:
build:
runs-on: "backend_runner"
steps:
- name: test
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
echo "Clone End"
2025-02-24 20:42:35 +08:00
# NET 發布
2025-02-24 20:48:20 +08:00
echo "發布 start"
2025-02-24 20:58:04 +08:00
# 切換到 Backend 目錄並確保存在
$backendPath = "D:\Code\Project\TCM\Backend"
if (Test-Path $backendPath) {
cd $backendPath
} else {
echo "錯誤: Backend 目錄不存在"
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
}
# 移除舊的 API 發布資料夾
$apiPath = "D:\Code\Server\TCM\API"
if (Test-Path $apiPath) {
Remove-Item -Recurse -Force $apiPath
}
# 確保目標資料夾存在
New-Item -Path $apiPath -ItemType Directory -Force | Out-Null
# 發布
dotnet publish -c Release -o $apiPath
if ($LASTEXITCODE -ne 0) {
echo "錯誤: dotnet publish 失敗"
exit 1
}
echo "發布 end"
2025-02-24 20:42:35 +08:00