Skip to content

Commit c5a73c9

Browse files
committed
Refactor deploy workflow to improve cache logic, update output paths, and enhance messaging for LevelLoader and Web UI
1 parent d80c61d commit c5a73c9

File tree

1 file changed

+9
-225
lines changed

1 file changed

+9
-225
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
release_branches: main,master
2929

3030
# --- 2. SETUP ENVIRONMENT ---
31-
# We install Python because you mentioned the bat file needs it
3231
- name: Setup Python
3332
uses: actions/setup-python@v5
3433
with:
@@ -68,16 +67,16 @@ jobs:
6867
id: cache-levelloader
6968
uses: actions/cache@v4
7069
with:
71-
# We cache the RESULT (the generated folder)
70+
# We cache the FINAL folder location
7271
path: Build/Admin/Mods/rm-levelloader
73-
# The key is the Commit Hash. If the repo updates, the key changes -> Cache Miss.
72+
# The key is the Commit Hash. If repo updates, cache is invalid -> Rebuild.
7473
key: levelloader-output-${{ steps.levelloader_hash.outputs.hash }}
7574

7675
- name: Run Generator (Only on Cache Miss)
7776
if: steps.cache-levelloader.outputs.cache-hit != 'true'
7877
working-directory: temp_loader
7978
run: |
80-
Write-Host "Cache miss! Running LevelLoader Generator..."
79+
Write-Host "Cache miss! New commit detected. Running LevelLoader Generator..."
8180
8281
# Patch Bat File (Fix slashes and remove pause)
8382
$content = Get-Content generate.bat -Raw
@@ -88,7 +87,7 @@ jobs:
8887
# Execute
8988
cmd /c generate.bat
9089
91-
# Move Output to Build Directory
90+
# Move Output to the Build Directory (So Cache can find it to save it)
9291
$Dest = "..\Build\Admin\Mods\rm-levelloader"
9392
9493
if (Test-Path "mods\rm-levelloader") {
@@ -127,7 +126,7 @@ jobs:
127126
if: steps.cache-webui.outputs.cache-hit != 'true'
128127
working-directory: Build/Admin/Mods/RealityMod/WebUI
129128
run: |
130-
Write-Host "Cache miss! Building WebUI..."
129+
Write-Host "Cache miss! WebUI files changed. Rebuilding..."
131130
pnpm install
132131
133132
# Inject Vextpack
@@ -202,8 +201,8 @@ jobs:
202201
# --- 8. PACKAGE & RELEASE ---
203202
- name: Create Zip Packages
204203
run: |
205-
Compress-Archive -Path Build\* -DestinationPath BF3-Server-Full.zip
206-
Compress-Archive -Path Build\Admin\Mods\* -DestinationPath BF3-Mods-Only.zip
204+
Compress-Archive -Path Build\* -DestinationPath realityMod-Server-Full.zip
205+
Compress-Archive -Path Build\Admin\Mods\* -DestinationPath realityMod-Mods-Only.zip
207206
208207
- name: Create Release
209208
uses: softprops/action-gh-release@v1
@@ -212,220 +211,5 @@ jobs:
212211
name: Release ${{ steps.tag_version.outputs.new_tag }}
213212
body: "Automated release."
214213
files: |
215-
BF3-Server-Full.zip
216-
BF3-Mods-Only.zipname: Auto Build & Release
217-
218-
on:
219-
push:
220-
branches: [ "main", "master" ]
221-
workflow_dispatch:
222-
223-
permissions:
224-
contents: write
225-
226-
jobs:
227-
auto-release:
228-
runs-on: windows-latest
229-
230-
steps:
231-
- name: Checkout Main Repo
232-
uses: actions/checkout@v4
233-
with:
234-
fetch-depth: 0
235-
236-
# --- 1. VERSIONING ---
237-
- name: Bump Version and Push Tag
238-
id: tag_version
239-
uses: mathieudutour/github-tag-action@v6.1
240-
with:
241-
github_token: ${{ secrets.GITHUB_TOKEN }}
242-
default_bump: patch
243-
release_branches: main,master
244-
245-
# --- 2. SETUP ENVIRONMENT ---
246-
# We install Python because you mentioned the bat file needs it
247-
- name: Setup Python
248-
uses: actions/setup-python@v5
249-
with:
250-
python-version: '3.10'
251-
252-
- name: Create Directory Structure
253-
run: |
254-
New-Item -ItemType Directory -Force -Path "Build\Admin\Mods"
255-
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\Documents\Battlefield 3\Server\Admin\Mods"
256-
257-
# --- 3. CLONE REPOS ---
258-
- name: Clone RealityMod & Mods
259-
working-directory: Build/Admin/Mods
260-
env:
261-
GH_TOKEN: ${{ secrets.GH_PAT }}
262-
run: |
263-
git clone --recurse-submodules https://oauth2:$env:GH_TOKEN@github.com/BF3RM/RealityMod.git
264-
git clone https://oauth2:$env:GH_TOKEN@github.com/BF3RM/BlueprintManager.git
265-
git clone https://oauth2:$env:GH_TOKEN@github.com/BF3RM/VEManager.git
266-
267-
- name: Clone RMLevelLoaderGen
268-
working-directory: ${{ github.workspace }}
269-
env:
270-
GH_TOKEN: ${{ secrets.GH_PAT }}
271-
run: |
272-
git clone --recurse-submodules https://oauth2:$env:GH_TOKEN@github.com/BF3RM/RMLevelLoaderGen.git temp_loader
273-
274-
# --- 4. CACHE LOGIC: LEVEL LOADER ---
275-
- name: Get LevelLoader Commit Hash
276-
id: levelloader_hash
277-
working-directory: temp_loader
278-
run: |
279-
$hash = git rev-parse HEAD
280-
echo "hash=$hash" >> $env:GITHUB_OUTPUT
281-
282-
- name: Cache LevelLoader Output
283-
id: cache-levelloader
284-
uses: actions/cache@v4
285-
with:
286-
# We cache the RESULT (the generated folder)
287-
path: Build/Admin/Mods/rm-levelloader
288-
# The key is the Commit Hash. If the repo updates, the key changes -> Cache Miss.
289-
key: levelloader-output-${{ steps.levelloader_hash.outputs.hash }}
290-
291-
- name: Run Generator (Only on Cache Miss)
292-
if: steps.cache-levelloader.outputs.cache-hit != 'true'
293-
working-directory: temp_loader
294-
run: |
295-
Write-Host "Cache miss! Running LevelLoader Generator..."
296-
297-
# Patch Bat File (Fix slashes and remove pause)
298-
$content = Get-Content generate.bat -Raw
299-
$content = $content -replace 'pause', 'REM pause'
300-
$content = $content -replace '/', '\'
301-
Set-Content -Path generate.bat -Value $content
302-
303-
# Execute
304-
cmd /c generate.bat
305-
306-
# Move Output to Build Directory
307-
$Dest = "..\Build\Admin\Mods\rm-levelloader"
308-
309-
if (Test-Path "mods\rm-levelloader") {
310-
Move-Item -Path "mods\rm-levelloader" -Destination $Dest -Force
311-
} elseif (Test-Path "$env:USERPROFILE\Documents\Battlefield 3\Server\Admin\Mods\RMLevelLoaderGen\mods\rm-levelloader") {
312-
Move-Item -Path "$env:USERPROFILE\Documents\Battlefield 3\Server\Admin\Mods\RMLevelLoaderGen\mods\rm-levelloader" -Destination $Dest -Force
313-
} else {
314-
Write-Error "FATAL: Output missing after generation"; exit 1
315-
}
316-
317-
# --- 5. CACHE LOGIC: WEB UI ---
318-
- name: Cache WebUI Output
319-
id: cache-webui
320-
uses: actions/cache@v4
321-
with:
322-
path: Build/Admin/Mods/RealityMod/ui.vuic
323-
# Key depends on Vextpack files AND the pnpm lockfile
324-
key: webui-vuic-${{ hashFiles('vextpack/**', 'Build/Admin/Mods/RealityMod/WebUI/pnpm-lock.yaml') }}
325-
326-
# --- 6. BUILD WEB UI (Only on Cache Miss) ---
327-
- name: Install pnpm
328-
if: steps.cache-webui.outputs.cache-hit != 'true'
329-
uses: pnpm/action-setup@v2
330-
with:
331-
version: 9
332-
333-
- name: Setup Node
334-
if: steps.cache-webui.outputs.cache-hit != 'true'
335-
uses: actions/setup-node@v4
336-
with:
337-
node-version: '20'
338-
cache: 'pnpm'
339-
cache-dependency-path: 'Build/Admin/Mods/RealityMod/WebUI/pnpm-lock.yaml'
340-
341-
- name: Build WebUI
342-
if: steps.cache-webui.outputs.cache-hit != 'true'
343-
working-directory: Build/Admin/Mods/RealityMod/WebUI
344-
run: |
345-
Write-Host "Cache miss! Building WebUI..."
346-
pnpm install
347-
348-
# Inject Vextpack
349-
$Source = "${{ github.workspace }}\vextpack"
350-
$Dest = "node_modules\vextpack"
351-
if (Test-Path $Source) {
352-
Copy-Item -Path $Source -Destination $Dest -Recurse -Force
353-
}
354-
355-
pnpm build
356-
357-
if (-not (Test-Path "..\ui.vuic")) { Write-Error "FAILURE: ui.vuic missing"; exit 1 }
358-
359-
# --- 7. CONFIG FILES ---
360-
- name: Generate Config Files
361-
working-directory: Build/Admin
362-
env:
363-
RCON_PW: ${{ secrets.RCON_PASSWORD }}
364-
LIC_KEY: ${{ secrets.LICENSE_KEY }}
365-
run: |
366-
New-Item -Path "BanList.txt" -ItemType File -Force
367-
Set-Content -Path "ModList.txt" -Value "RealityMod`r`nrm-levelloader`r`nBlueprintManager`r`nVEManager"
368-
369-
$mapListContent = @"
370-
#AAS Layers
371-
#XP1_001 AdvanceAndSecureStd 1 # Strike at Karkand
372-
#XP1_002 AdvanceAndSecureStd 1 # Gulf of Oman
373-
#XP1_003 AdvanceAndSecureStd 1 # Sharqi Peninsula
374-
#XP1_004 AdvanceAndSecureStd 1 # Wake Island
375-
#XP3_Desert AdvanceAndSecureStd 1 # Bandar Desert
376-
#XP3_Shield AdvanceAndSecureStd 6 # Issue 226
377-
#XP4_Parl AdvanceAndSecureStd 1 # Azadi Palace
378-
#XP5_001 AdvanceAndSecureStd 1 # Operation Riverside
379-
XP5_002 AdvanceAndSecureStd 1 # Kandahar
380-
#XP5_003 AdvanceAndSecureStd 1 # Bay of Gdansk
381-
#XP5_004 AdvanceAndSecureStd 1 # Chernihivska Oblast Pipeline
382-
"@
383-
Set-Content -Path "MapList.txt" -Value $mapListContent
384-
385-
$startupContent = @"
386-
# RM Server Startup.txt Example
387-
admin.password "$env:RCON_PW"
388-
vars.gamePassword "password"
389-
vars.serverName "<Server Name>"
390-
vars.maxPlayers 80
391-
vu.serverbanner https://i.imgur.com/B4bCwpq.jpg
392-
vars.idleTimeout 9999
393-
vars.teamKillCountForKick 0
394-
vars.teamKillValueForKick 2
395-
vars.teamKillValueIncrease 0.525
396-
vars.teamKillValueDecreasePerSecond 0.01
397-
vars.teamKillKickForBan 0
398-
RM.setDevelopers "names" "space" "seperated"
399-
RM.setAdmins "[ENTE]VileEnd" "Admin2"
400-
RM.setLightAdmins "LightAdmin1" "LightAdmin2"
401-
RM.serverInfo "Sample RM Server Info"
402-
RM.serverLicenseKey $env:LIC_KEY
403-
RM.ingameBanner https://i.imgur.com/Vth3wBa.jpg
404-
RM.pingLimitEnable true
405-
RM.pingLimitInMs 250
406-
RM.autoPerfEnabled false
407-
RM.autoPerfMaxPlayers 80
408-
RM.tempReservedSlotsEnabled true
409-
RM.tempReservedSlotsRejoinTime 60.0
410-
RM.defaultPreRoundTime 180
411-
RM.setAutoBalancer false
412-
reservedSlotsList.add "PlayerName1"
413-
reservedSlotsList.add "PlayerName2"
414-
"@
415-
Set-Content -Path "Startup.txt" -Value $startupContent
416-
417-
# --- 8. PACKAGE & RELEASE ---
418-
- name: Create Zip Packages
419-
run: |
420-
Compress-Archive -Path Build\* -DestinationPath Reality-Server-Full.zip
421-
Compress-Archive -Path Build\Admin\Mods\* -DestinationPath Reality-Mods-Only.zip
422-
423-
- name: Create Release
424-
uses: softprops/action-gh-release@v1
425-
with:
426-
tag_name: ${{ steps.tag_version.outputs.new_tag }}
427-
name: Release ${{ steps.tag_version.outputs.new_tag }}
428-
body: "Automated release."
429-
files: |
430-
Reality-Server-Full.zip
431-
Reality-Mods-Only.zip
214+
realityMod-Server-Full.zip
215+
realityMod-Mods-Only.zip

0 commit comments

Comments
 (0)