Skip to content

Commit 439549f

Browse files
Merge pull request #36 from sipsuru/main
feat: Allow configuring patch server port at build time
2 parents 0831022 + 0edfdc8 commit 439549f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.github/workflows/cp_dispatch.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ on:
1414
options:
1515
- Windows (x86_64)
1616
- Linux (x86_64)
17+
patch-server-port:
18+
description: 'Patch server port (useful for resolving port conflicts)"'
19+
required: true
20+
default: '5678'
1721

1822
env:
1923
OS_ARCH: ${{ github.event.inputs.os-and-arch }}
2024
VERSION_TO_PATCH: ${{ github.event.inputs.version_to_patch }}
25+
PATCH_SERVER_PORT: ${{ github.event.inputs.patch-server-port }}
2126

2227
jobs:
2328

@@ -462,6 +467,19 @@ jobs:
462467
}
463468
shell: pwsh
464469

470+
- name: Set patch server port (in main.js of server)
471+
run: |
472+
$source_index = "msojocs-patch/server/index.js"
473+
$index_content = Get-Content -Path $source_index -Raw
474+
475+
if (Test-Path $source_index) {
476+
$index_content = $index_content -replace 'const port = \d+;', "const port = $env:PATCH_SERVER_PORT;"
477+
Set-Content -Path $source_index -Value $index_content
478+
Write-Host "Server port set to $env:PATCH_SERVER_PORT"
479+
} else {
480+
Write-Host "index.js (from server) not found"
481+
}
482+
465483
- name: Patch main.js to main.original.js
466484
run: |
467485
$source_main = "FE/resources/app/out/main.js"

.github/workflows/cp_latest_dispatch.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ on:
1111
options:
1212
- Windows (x86_64)
1313
- Linux (x86_64)
14+
patch-server-port:
15+
description: 'Patch server port (useful for resolving port conflicts)"'
16+
required: true
17+
default: '5678'
1418

1519
env:
1620
OS_ARCH: ${{ github.event.inputs.os-and-arch }}
21+
PATCH_SERVER_PORT: ${{ github.event.inputs.patch-server-port }}
1722

1823
jobs:
1924

@@ -439,6 +444,19 @@ jobs:
439444
}
440445
shell: pwsh
441446

447+
- name: Set patch server port (in main.js of server)
448+
run: |
449+
$source_index = "msojocs-patch/server/index.js"
450+
$index_content = Get-Content -Path $source_index -Raw
451+
452+
if (Test-Path $source_index) {
453+
$index_content = $index_content -replace 'const port = \d+;', "const port = $env:PATCH_SERVER_PORT;"
454+
Set-Content -Path $source_index -Value $index_content
455+
Write-Host "Server port set to $env:PATCH_SERVER_PORT"
456+
} else {
457+
Write-Host "index.js (from server) not found"
458+
}
459+
442460
- name: Patch main.js to main.original.js
443461
run: |
444462
$source_main = "FE/resources/app/out/main.js"

0 commit comments

Comments
 (0)