35 lines
1.2 KiB
PowerShell
35 lines
1.2 KiB
PowerShell
param(
|
|
[string]$Server = "ginnoir@valhalla",
|
|
[string]$RemotePath = "/config/caddy/site/romhacks-wiki"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
$RepoRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
$Dist = Join-Path $RepoRoot "dist"
|
|
$Archive = Join-Path $env:TEMP "romhack-archive-dist.tar"
|
|
|
|
if (-not (Test-Path $Dist)) {
|
|
throw "dist/ does not exist. Run npm run build first."
|
|
}
|
|
|
|
if ([string]::IsNullOrWhiteSpace($RemotePath) -or -not $RemotePath.StartsWith("/config/caddy/site/")) {
|
|
throw "RemotePath must be under /config/caddy/site/."
|
|
}
|
|
|
|
if (Test-Path $Archive) {
|
|
Remove-Item -LiteralPath $Archive -Force
|
|
}
|
|
|
|
Write-Host "Packing built site ..."
|
|
tar -C $Dist -cf $Archive .
|
|
|
|
Write-Host "Syncing built site to ${Server}:$RemotePath ..."
|
|
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 ..."
|
|
ssh $Server "docker exec caddy caddy reload --config /etc/caddy/Caddyfile"
|
|
|
|
Write-Host "Deployed ROM Hack Archive to https://romhacks.ginnoir.com"
|