[CLAUDE] Scripts: rewrite 4 deploy PS1 ASCII-only for PS 5.1 compat
Some checks failed
Deploy SOLUTION_ERP / build-backend (push) Failing after 9s
Deploy SOLUTION_ERP / build-fe-admin (push) Has been cancelled
Deploy SOLUTION_ERP / build-fe-user (push) Has been cancelled
Deploy SOLUTION_ERP / deploy-iis (push) Has been cancelled

PowerShell 5.1 reads .ps1 files as locale codepage (not UTF-8 no BOM),
which corrupts multi-byte Vietnamese chars and breaks parsing. Rewrote
setup-iis-sites.ps1, setup-ssl.ps1, setup-gitea-runner.ps1, deploy-all.ps1
as ASCII-only. Also renamed $Host param to $HostName in Ensure-Site to
avoid collision with PowerShell built-in $Host automatic variable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-21 14:17:36 +07:00
parent 85acf750b3
commit 169e268b28
4 changed files with 131 additions and 137 deletions

View File

@ -1,12 +1,12 @@
# Register Gitea Actions runner trên VPS Windows Server.
# Có thể dùng chung với VIETREPORT (runner có thể serve nhiều repo qua labels).
# Register Gitea Actions runner on VPS Windows Server.
# Can be shared with VIETREPORT (runner serves multiple repos via labels).
#
# Usage (admin PowerShell):
# .\setup-gitea-runner.ps1 -RegistrationToken 'xxxx' -RunnerName 'vps-win-01'
#
# Lấy RegistrationToken từ:
# Get RegistrationToken from:
# https://git.baocaogiaoduc.vn/-/admin/actions/runners (admin only)
# hoặc per-repo: https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp/settings/actions/runners
# or per-repo: https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp/settings/actions/runners
param(
[Parameter(Mandatory=$true)] [string]$RegistrationToken,
@ -25,7 +25,7 @@ if (-not (Test-Path $RunnerExe)) {
Write-Host "==> Download Gitea act_runner" -ForegroundColor Cyan
if (-not (Test-Path $InstallDir)) { New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null }
# Latest release từ Gitea
# Latest release from Gitea CDN
$url = "https://dl.gitea.com/act_runner/act_runner-windows-amd64.exe"
Invoke-WebRequest -Uri $url -OutFile $RunnerExe -UseBasicParsing
Write-Host " Downloaded $RunnerExe"
@ -35,7 +35,8 @@ if (-not (Test-Path $RunnerExe)) {
Set-Location $InstallDir
if (-not (Test-Path (Join-Path $InstallDir ".runner"))) {
Write-Host "`n==> Register với Gitea $GiteaUrl" -ForegroundColor Cyan
Write-Host ""
Write-Host "==> Register with Gitea $GiteaUrl" -ForegroundColor Cyan
& $RunnerExe register `
--no-interactive `
--instance $GiteaUrl `
@ -43,23 +44,22 @@ if (-not (Test-Path (Join-Path $InstallDir ".runner"))) {
--name $RunnerName `
--labels $Labels
if ($LASTEXITCODE -ne 0) {
Write-Error "Register fail. Check:`n- Token đúng?`n- GiteaUrl reachable?`n- Runner name '$RunnerName' đã dùng?"
Write-Error "Register fail. Check: token correct? GiteaUrl reachable? Runner name '$RunnerName' already used?"
exit 1
}
Write-Host " Registered as '$RunnerName'"
} else {
Write-Host " Runner đã register (.runner file exists)"
Write-Host " Runner already registered (.runner file exists)"
}
# ===================== 3. Install as Windows service =====================
$ServiceName = "gitea-runner"
$svc = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if (-not $svc) {
Write-Host "`n==> Install Windows service" -ForegroundColor Cyan
# act_runner không có built-in service install — dùng nssm hoặc sc.exe
# Dùng sc.exe đơn giản:
$escapedPath = $RunnerExe -replace '\\', '\\'
sc.exe create $ServiceName binPath= "`"$escapedPath`" daemon --config `"$InstallDir\config.yml`"" start= auto DisplayName= "Gitea Actions Runner"
Write-Host ""
Write-Host "==> Install Windows service" -ForegroundColor Cyan
# act_runner has no built-in service install - use sc.exe
sc.exe create $ServiceName binPath= "`"$RunnerExe`" daemon --config `"$InstallDir\config.yml`"" start= auto DisplayName= "Gitea Actions Runner"
Start-Service $ServiceName
Write-Host " Service '$ServiceName' installed + started"
} else {
@ -71,7 +71,8 @@ if (-not $svc) {
}
}
Write-Host "`n✅ Runner setup DONE" -ForegroundColor Green
Write-Host " Check trên Gitea: $GiteaUrl/-/admin/actions/runners (admin) hoặc repo settings > Actions > Runners"
Write-Host ""
Write-Host "[OK] Runner setup DONE" -ForegroundColor Green
Write-Host " Check on Gitea: $GiteaUrl/-/admin/actions/runners (admin) or repo settings > Actions > Runners"
Write-Host " Labels: $Labels"
Write-Host " Log: Get-Content '$InstallDir\log.txt' -Tail 50 -Wait"