feat(deploy): v0.7.0 一键上传脚本(Windows PS) + nginx 脱敏脚本

upload-frontend-v0.7.0.ps1:
- 自动打包 4 端 dist + scp + ssh 解压
- 用户只需在 PowerShell 跑一次

nginx-access-log-redact.sh:
- 自定义 log_format(去掉 Authorization/Cookie)
- 支持 --rollback 回滚
- nginx -t 验证语法 + nginx -s reload 热重载

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Simon
2026-06-21 11:56:48 +08:00
parent e47f750b9e
commit 627f4aa924
2 changed files with 136 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
# =============================================================================
# v0.7.0 前端 dist 一键上传到生产
# =============================================================================
# 用途:打包 4 端 dist + scp 到生产 + 在生产解压 + 重载 nginx
# 用法:在 Windows PowerShell 7+ 跑 .\upload-frontend-v0.7.0.ps1
# 前置:已 PuTTY 跳到堡垒机 → 再到生产(同一会话)
# =============================================================================
$ErrorActionPreference = "Stop"
$ProjectRoot = "D:\资料\03-项目开发\wecom_it_smart_desk-claude"
$TarPath = "$env:TEMP\frontend-v0.7.0.tar.gz"
$Server = "root@10.90.5.110"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " v0.7.0 前端 dist 一键上传" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 步骤 1:打包 4 端 dist
Write-Host "[1/4] 打包 4 端 dist..." -ForegroundColor Yellow
Set-Location $ProjectRoot
& tar -czf $TarPath `
frontend-admin/dist `
frontend-agent/dist `
frontend-portal/dist `
frontend-h5/dist
$Size = (Get-Item $TarPath).Length / 1MB
Write-Host " OK: $TarPath ($([math]::Round($Size, 2)) MB)" -ForegroundColor Green
# 步骤 2:scp 到生产
Write-Host ""
Write-Host "[2/4] scp 到生产 $Server:/tmp/..." -ForegroundColor Yellow
Write-Host " (会提示输入密码,用 PuTTY 的密码)" -ForegroundColor Gray
& scp -o StrictHostKeyChecking=no -o ConnectTimeout=30 $TarPath "${Server}:/tmp/frontend-v0.7.0.tar.gz"
if ($LASTEXITCODE -ne 0) {
Write-Host " FAILED: scp 失败" -ForegroundColor Red
exit 1
}
Write-Host " OK" -ForegroundColor Green
# 步骤 3:在生产解压(走 ssh,需要输密码)
Write-Host ""
Write-Host "[3/4] ssh 到生产解压到 nginx 挂载点..." -ForegroundColor Yellow
Write-Host " (会再次提示输入密码)" -ForegroundColor Gray
$RemoteCmd = @"
cd /opt/wecom-it-desk &&
echo '...' &&
sudo tar -xzf /tmp/frontend-v0.7.0.tar.gz &&
echo ' tar ...' &&
sudo rm /tmp/frontend-v0.7.0.tar.gz &&
echo ' tar ...' &&
rm $TarPath &&
echo '========================================' &&
echo ' 4 dist !' &&
echo '========================================'
"@
& ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 $Server $RemoteCmd
if ($LASTEXITCODE -ne 0) {
Write-Host " FAILED: ssh 解压失败" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "[4/4] 完成!" -ForegroundColor Green
Write-Host "下一步:在生产跑 nginx 脱敏配置 + reload" -ForegroundColor Cyan
Write-Host "详见 docs/DEPLOY-QUICK-v0.7.0.md Step 5-6" -ForegroundColor Cyan