From b54fa5c6aee1553fa005ca36cb4426e77db51dd3 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Thu, 16 Jul 2026 21:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E9=80=9A=E7=9F=A5=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E7=94=9F=E4=BA=A7=E8=84=9A=E6=9C=AC=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/git-build-deploy.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/git-build-deploy.ps1 b/scripts/git-build-deploy.ps1 index 4db7250..dff7779 100644 --- a/scripts/git-build-deploy.ps1 +++ b/scripts/git-build-deploy.ps1 @@ -205,6 +205,23 @@ foreach ($entry in $replacements.GetEnumerator()) { } $remoteScript = $remoteScript.Replace("`r`n", "`n") +# Freeze production-script bytes locally before crossing PowerShell, Bash, and SSH. +$productionBlockPatternText = '(?ms)^production_script="\$\(cat <<' + [char]39 + 'PRODUCTION' + [char]39 + '\n(?.*?)\nPRODUCTION\n\)"\n\nproduction_script_base64=.*?$' +$productionBlockPattern = [regex]$productionBlockPatternText +$productionBlockMatch = $productionBlockPattern.Match($remoteScript) +if (-not $productionBlockMatch.Success) { + throw 'Cannot extract the production deployment script; release aborted.' +} +$productionScriptBytes = [System.Text.Encoding]::UTF8.GetBytes( + $productionBlockMatch.Groups['body'].Value + "`n" +) +$productionScriptBase64 = [Convert]::ToBase64String($productionScriptBytes) +$productionBlockReplacement = "production_script_base64=$(ConvertTo-ShellSingleQuoted $productionScriptBase64)" +$remoteScript = $remoteScript.Remove( + $productionBlockMatch.Index, + $productionBlockMatch.Length +).Insert($productionBlockMatch.Index, $productionBlockReplacement) + $localTemp = Join-Path ([System.IO.Path]::GetTempPath()) ("yyd-notification-deploy-{0}.sh" -f [guid]::NewGuid().ToString('N')) $remoteTemp = "/tmp/$(Split-Path $localTemp -Leaf)" try {