From 817d11a88d9e490c861367aa92cafc803e0e902e Mon Sep 17 00:00:00 2001 From: fiatcode Date: Fri, 23 Jan 2026 09:19:03 +0700 Subject: [PATCH] feat: add deployment script for automated site deployment using WinSCP --- deploy.ps1 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 deploy.ps1 diff --git a/deploy.ps1 b/deploy.ps1 new file mode 100644 index 0000000..c377267 --- /dev/null +++ b/deploy.ps1 @@ -0,0 +1,33 @@ +# Variables +$remoteUser = "dhemas" +$remoteHost = "dhemasnurjaya.com" +$remoteDir = "/home/dhemas/apps/blog/public/" +$localDir = "dist/" +$keyPath = "D:\Secrets\giocloud-default.ppk" +$winscpExecutable = "C:\Users\dhemas\AppData\Local\Programs\WinSCP\WinSCP.com" # Update this if needed + +# Build astro site +npm run build +if ($LASTEXITCODE -ne 0) { + Write-Host "Build failed!" -ForegroundColor Red + exit 1 +} + +# Generate WinSCP sync commands +$scriptContent = @" +open sftp://$remoteUser@$remoteHost -privatekey=$keyPath +synchronize remote -delete -criteria=checksum $localDir $remoteDir +exit +"@ + +# Save the script to a temporary file +$tempScript = [System.IO.Path]::GetTempFileName() +Set-Content -Path $tempScript -Value $scriptContent + +# Execute the WinSCP command +& $winscpExecutable /script=$tempScript + +# Clean up +Remove-Item $tempScript + +Write-Host "Deployed to $remoteHost!"