blob: 030a2ce7c3d46dec259dd3d1c382c4e1c8d9945f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# Deploy: build and push dist/ to XServer via git
# - Git delta compression: only changes are transferred (fast)
# - *.yasutakeyohei.com folders are protected by .gitignore
# Prerequisite: `ssh xserver` works (configured in ~/.ssh/config)
# Usage: .\deploy.ps1
param(
[string]$Remote = "xserver:/home/wais/yasutakeyohei.com/repo.git"
)
$ErrorActionPreference = "Stop"
Write-Host "=== Build ===" -ForegroundColor Cyan
npm run build
if ($LASTEXITCODE -ne 0) { throw "Build failed." }
Write-Host ""
Write-Host "=== Deploy ===" -ForegroundColor Cyan
Write-Host "Target: $Remote"
$deployDir = ".deploy"
# 前回の .deploy を削除
if (Test-Path $deployDir) { Remove-Item -Recurse -Force $deployDir }
# dist/ をコピー
Copy-Item -Recurse dist $deployDir
# git 操作
Push-Location $deployDir
try {
git init
git add -A
git commit -m "deploy" --allow-empty --quiet
git push -f $Remote main
} finally {
Pop-Location
}
Write-Host "Done." -ForegroundColor Green
|