Skip to content

Commit f2ca6b8

Browse files
committed
Refactor deploy workflow to enhance clarity and improve error handling in cloning and building processes
1 parent b53c222 commit f2ca6b8

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
run: |
1818
New-Item -ItemType Directory -Force -Path "Build\Admin\Mods"
1919
20+
# --- 1. CLONE REALITYMOD & MODS ---
2021
- name: Clone RealityMod & Mods
2122
working-directory: Build/Admin/Mods
2223
env:
@@ -26,18 +27,21 @@ jobs:
2627
git clone https://oauth2:$env:GH_TOKEN@github.com/BF3RM/BlueprintManager.git
2728
git clone https://oauth2:$env:GH_TOKEN@github.com/BF3RM/VEManager.git
2829
30+
# --- 2. INSTALL PNPM ---
2931
- name: Install pnpm
3032
uses: pnpm/action-setup@v2
3133
with:
3234
version: 9
3335

36+
# --- 3. SETUP NODE & CACHE ---
3437
- name: Setup Node.js with Caching
3538
uses: actions/setup-node@v4
3639
with:
3740
node-version: '20'
3841
cache: 'pnpm'
3942
cache-dependency-path: 'Build/Admin/Mods/RealityMod/WebUI/pnpm-lock.yaml'
4043

44+
# --- 4. BUILD WEBUI ---
4145
- name: Install & Inject Vextpack & Build
4246
working-directory: Build/Admin/Mods/RealityMod/WebUI
4347
run: |
@@ -52,11 +56,13 @@ jobs:
5256
5357
pnpm build
5458
59+
# Check for ui.vuic in parent folder (RealityMod root)
5560
if (-not (Test-Path "..\ui.vuic")) {
56-
Write-Error "FAILURE: ui.vuic was not found in ../ui.vuic!"
61+
Write-Error "FAILURE: ui.vuic was not found in RealityMod root!"
5762
exit 1
5863
}
5964
65+
# --- 5. RM LEVEL LOADER GEN (Fixed & Patched) ---
6066
- name: Run RMLevelLoaderGen
6167
working-directory: ${{ github.workspace }}
6268
env:
@@ -65,23 +71,38 @@ jobs:
6571
git clone https://oauth2:$env:GH_TOKEN@github.com/BF3RM/RMLevelLoaderGen.git temp_loader
6672
cd temp_loader
6773
68-
(Get-Content generate.bat) -replace 'pause', 'REM pause' | Set-Content generate.bat
74+
Write-Host "--- Patching generate.bat ---"
75+
# 1. Read Content
76+
$content = Get-Content generate.bat -Raw
6977
70-
cmd /c "echo. | generate.bat"
78+
# 2. Fix: Remove 'pause'
79+
$content = $content -replace 'pause', 'REM pause'
80+
81+
# 3. Fix: Replace Linux style ./ with Windows .\ (Fixes '.' is not recognized)
82+
$content = $content -replace '\./', '.\'
83+
84+
# 4. Save and Print
85+
Set-Content -Path generate.bat -Value $content
86+
Write-Host $content
87+
88+
Write-Host "--- Running generate.bat ---"
89+
cmd /c generate.bat
7190
72-
$LocalPath = "mods\rm-levelloader"
73-
$DocPath = "$env:USERPROFILE\Documents\Battlefield 3\Server\Admin\Mods\RMLevelLoaderGen\mods\rm-levelloader"
91+
Write-Host "--- Searching for output ---"
7492
$Dest = "..\Build\Admin\Mods\rm-levelloader"
93+
94+
# Search recursively in the User Profile (Documents, etc) and current dir for the folder
95+
$Found = Get-ChildItem -Path "$env:USERPROFILE" -Filter "rm-levelloader" -Recurse -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
7596
76-
if (Test-Path $LocalPath) {
77-
Move-Item -Path $LocalPath -Destination $Dest -Force
78-
} elseif (Test-Path $DocPath) {
79-
Move-Item -Path $DocPath -Destination $Dest -Force
97+
if ($Found) {
98+
Write-Host "Found generated folder at: $($Found.FullName)"
99+
Move-Item -Path $Found.FullName -Destination $Dest -Force
80100
} else {
81-
Write-Error "Could not find generated rm-levelloader folder."
101+
Write-Error "FATAL: Could not find 'rm-levelloader' folder anywhere in $env:USERPROFILE"
82102
exit 1
83103
}
84104
105+
# --- 6. CONFIG FILES ---
85106
- name: Generate Config Files
86107
working-directory: Build/Admin
87108
env:
@@ -113,20 +134,17 @@ jobs:
113134
admin.password "$env:RCON_PW"
114135
vars.gamePassword "password"
115136
116-
# Server
117137
vars.serverName "<Server Name>"
118138
vars.maxPlayers 80
119139
vu.serverbanner https://i.imgur.com/B4bCwpq.jpg
120140
vars.idleTimeout 9999
121141
122-
# Teamkilling
123142
vars.teamKillCountForKick 0
124143
vars.teamKillValueForKick 2
125144
vars.teamKillValueIncrease 0.525
126145
vars.teamKillValueDecreasePerSecond 0.01
127146
vars.teamKillKickForBan 0
128147
129-
# RM Commands
130148
RM.setDevelopers "names" "space" "seperated"
131149
RM.setAdmins "[ENTE]VileEnd" "Admin2"
132150
RM.setLightAdmins "LightAdmin1" "LightAdmin2"
@@ -142,14 +160,14 @@ jobs:
142160
RM.defaultPreRoundTime 180
143161
RM.setAutoBalancer false
144162
145-
# Reserved Slots
146163
reservedSlotsList.add "PlayerName1"
147164
reservedSlotsList.add "PlayerName2"
148165
"@
149166
Set-Content -Path "Startup.txt" -Value $startupContent
150167
168+
# --- 7. FINALIZE ---
151169
- name: Upload Server Artifact
152170
uses: actions/upload-artifact@v4
153171
with:
154172
name: BF3-Server-Files
155-
path: Build/
173+
path: Build/

0 commit comments

Comments
 (0)