fix: deploy site archive as file

This commit is contained in:
ginnoir
2026-06-08 21:24:00 -05:00
parent 0017a5d10c
commit e566ef4a51
+10 -3
View File
@@ -4,8 +4,10 @@ param(
) )
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
$RepoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) $RepoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
$Dist = Join-Path $RepoRoot "dist" $Dist = Join-Path $RepoRoot "dist"
$Archive = Join-Path $env:TEMP "romhack-archive-dist.tar"
if (-not (Test-Path $Dist)) { if (-not (Test-Path $Dist)) {
throw "dist/ does not exist. Run npm run build first." throw "dist/ does not exist. Run npm run build first."
@@ -15,11 +17,16 @@ if ([string]::IsNullOrWhiteSpace($RemotePath) -or -not $RemotePath.StartsWith("/
throw "RemotePath must be under /config/caddy/site/." throw "RemotePath must be under /config/caddy/site/."
} }
Write-Host "Preparing remote site directory $RemotePath ..." if (Test-Path $Archive) {
ssh $Server "rm -rf '$RemotePath' && mkdir -p '$RemotePath'" Remove-Item -LiteralPath $Archive -Force
}
Write-Host "Packing built site ..."
tar -C $Dist -cf $Archive .
Write-Host "Syncing built site to ${Server}:$RemotePath ..." Write-Host "Syncing built site to ${Server}:$RemotePath ..."
tar -C $Dist -cf - . | ssh $Server "tar -C '$RemotePath' -xf -" scp $Archive "${Server}:/tmp/romhack-archive-dist.tar"
ssh $Server "rm -rf '$RemotePath' && mkdir -p '$RemotePath' && tar -C '$RemotePath' -xf /tmp/romhack-archive-dist.tar && rm /tmp/romhack-archive-dist.tar"
Write-Host "Reloading Caddy ..." Write-Host "Reloading Caddy ..."
ssh $Server "docker exec caddy caddy reload --config /etc/caddy/Caddyfile" ssh $Server "docker exec caddy caddy reload --config /etc/caddy/Caddyfile"