Preserve ship release manifest on deploy

This commit is contained in:
2026-07-07 15:34:47 +09:00
parent 0bbb51e240
commit 942ab3d9d3

View File

@@ -57,14 +57,33 @@ $fullCommit = (git rev-parse HEAD).Trim()
$commit = (git rev-parse --short=8 HEAD).Trim()
$qaVersion = if ($env:PUBLIC_QA_VERSION) { $env:PUBLIC_QA_VERSION } else { "deploy-$timestamp" }
$releaseManifestPath = Join-Path $dist "release-manifest.json"
@{
app = "heros_web"
commit = $fullCommit
shortCommit = $commit
qaVersion = $qaVersion
generatedAt = (Get-Date).ToUniversalTime().ToString("o")
} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $releaseManifestPath -Encoding UTF8
Write-Host "Wrote $releaseManifestPath for $commit ($qaVersion)"
$writeReleaseManifest = $true
if (Test-Path $releaseManifestPath -PathType Leaf) {
try {
$existingReleaseManifest = Get-Content -LiteralPath $releaseManifestPath -Raw | ConvertFrom-Json
if ($existingReleaseManifest.app -ne "heros_web") {
throw "Existing release manifest has unexpected app '$($existingReleaseManifest.app)'."
}
if ($existingReleaseManifest.commit -eq $fullCommit) {
$writeReleaseManifest = $false
Write-Host "Using existing $releaseManifestPath for $commit"
} else {
Write-Host "Replacing stale $releaseManifestPath commit $($existingReleaseManifest.commit) with $commit"
}
} catch {
throw "Invalid existing release manifest at $releaseManifestPath. $_"
}
}
if ($writeReleaseManifest) {
@{
app = "heros_web"
commit = $fullCommit
shortCommit = $commit
qaVersion = $qaVersion
generatedAt = (Get-Date).ToUniversalTime().ToString("o")
} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $releaseManifestPath -Encoding UTF8
Write-Host "Wrote $releaseManifestPath for $commit ($qaVersion)"
}
$userHost = "$SshUser@$SshHost"
$remoteTemp = "$RemoteRoot/.$($SiteName)_deploy_$timestamp"