test_main
This commit is contained in:
parent
319aed04f7
commit
2a701e3ce2
56
.gitea/workflows/main.yml
Normal file
56
.gitea/workflows/main.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
name: Backend_main # 工作流的名称
|
||||||
|
|
||||||
|
# 当有代码推送到仓库的 develop 分支时,这个 Actions 工作流会被触发并执行
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: "backend_runner"
|
||||||
|
steps:
|
||||||
|
- name: test
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
echo "Git clone_start"
|
||||||
|
|
||||||
|
# 設定變數
|
||||||
|
$projectPath = "D:\Code\Project\TCM_main"
|
||||||
|
$backendPath = "D:\Code\Project\TCM_main\Backend"
|
||||||
|
$apiPath = "D:\Code\Server\TCM\API_main"
|
||||||
|
|
||||||
|
cd D:\Code\Project\TCM_main
|
||||||
|
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 main http://leovip125.ddns.net:8418/TCM/Backend.git
|
||||||
|
echo "Clone End"
|
||||||
|
|
||||||
|
# .NET 發布
|
||||||
|
echo "發布 start"
|
||||||
|
|
||||||
|
# 切換到 Backend 目錄
|
||||||
|
cd $backendPath
|
||||||
|
if ($LASTEXITCODE -ne 0) { exit 1}
|
||||||
|
|
||||||
|
# 還原與建置
|
||||||
|
dotnet restore
|
||||||
|
if ($LASTEXITCODE -ne 0) {exit 1 }
|
||||||
|
|
||||||
|
dotnet build --configuration Release
|
||||||
|
if ($LASTEXITCODE -ne 0) { exit 1}
|
||||||
|
|
||||||
|
# 移除舊的 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) {exit 1 }
|
||||||
|
|
||||||
|
echo "發布 end"
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user