-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.44 KB
/
Copy pathdeploy.yml
File metadata and controls
82 lines (69 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: GameServer Self-Hosted Deploy
on:
push:
branches: [ "master" ]
jobs:
build-and-run:
runs-on: self-hosted
env:
RUNNER_TRACKING_ID: ""
steps:
- name: Stop Server
shell: powershell
run: |
$proc = Get-Process -Name "C#_GameServer" -ErrorAction SilentlyContinue
if ($proc) {
Stop-Process -Name "C#_GameServer" -Force
Start-Sleep -Seconds 2
Write-Host "Stop Server"
}
- name: Checkout Code
uses: actions/checkout@v3
- name: NuGet Restore
run: nuget restore "C#_GameServer.sln"
- name: Build Project
run: |
$publishDir = Join-Path $pwd "publish"
msbuild "C#_GameServer.sln" /p:Configuration=Release /p:OutputPath=$publishDir
- name: Create db.config from Secrets
shell: powershell
run: |
$configContent = @"
${{ secrets.DB_CONFIG }}
"@
$configContent | Out-File -FilePath "publish\db.config" -Encoding utf8
- name: Clean and Copy GameData
run: |
$targetData = Join-Path $pwd "publish\GameData"
if (Test-Path $targetData) {
Remove-Item -Path $targetData -Recurse -Force
}
xcopy "GameData" $targetData /E /I /Y
- name: Restart Server
shell: powershell
run: |
$exePath = Join-Path $pwd "publish\C#_GameServer.exe"
$workDir = Join-Path $pwd "publish"
Write-Host "Starting Server: $exePath"
Start-Process -FilePath $exePath -WorkingDirectory $workDir
Start-Sleep -Seconds 5
- name: Run Integration Tests
shell: powershell
run: |
Write-Host "Running Integration Tests via VSTest..."
vstest.console.exe "publish\UnitTestProject1.dll" "/logger:console;verbosity=detailed"
if ($LASTEXITCODE -ne 0) {
Write-Error "Integration Tests Failed!"
$procName = "C#_GameServer"
Stop-Process -Name $procName -Force -ErrorAction SilentlyContinue
exit 1
}
- name: End
run: |
$check = Get-Process -Name "C#_GameServer" -ErrorAction SilentlyContinue
if ($check) {
Write-Host "Server is running successfully after tests. PID: $($check.Id)"
} else {
Write-Error "Server died after tests!"
exit 1
}