feat: add deployment script for automated site deployment using WinSCP
This commit is contained in:
parent
95875316c8
commit
817d11a88d
1 changed files with 33 additions and 0 deletions
33
deploy.ps1
Normal file
33
deploy.ps1
Normal file
|
|
@ -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!"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue