diff --git a/scripts/deploy-site.ps1 b/scripts/deploy-site.ps1 index 97e5ff2..b1596ae 100644 --- a/scripts/deploy-site.ps1 +++ b/scripts/deploy-site.ps1 @@ -11,11 +11,15 @@ 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/." +} + Write-Host "Preparing remote site directory $RemotePath ..." -ssh $Server "mkdir -p '$RemotePath'" +ssh $Server "rm -rf '$RemotePath' && mkdir -p '$RemotePath'" Write-Host "Syncing built site to ${Server}:$RemotePath ..." -scp -r (Join-Path $Dist "*") "${Server}:$RemotePath/" +tar -C $Dist -cf - . | ssh $Server "tar -C '$RemotePath' -xf -" Write-Host "Reloading Caddy ..." ssh $Server "docker exec caddy caddy reload --config /etc/caddy/Caddyfile"