This commit is contained in:
ponzischeme89
2026-08-11 23:41:10 +12:00
parent 0e183cf560
commit 5fed3360c2
42 changed files with 1340 additions and 130 deletions
+32 -8
View File
@@ -13,8 +13,8 @@ The remote deployment:
- installs .env from the local .env.example, overwriting the deployed
copy, and keeps the old one alongside as .env.previous;
- preserves the named database volume;
- tells every signed-in television a deployment is starting, through the
gateway that is still running, before the build begins;
- unless --Quiet is supplied, tells every signed-in television a deployment
is starting through the gateway that is still running before the build begins;
- pulls Redis and PostgreSQL, then builds the Memby server;
- starts each service and waits for its health check;
- restores the previous application files if activation fails.
@@ -38,6 +38,9 @@ This deploys the current local working tree, including uncommitted server change
.EXAMPLE
.\deploy-server.ps1 -ReleaseNotes 'Required security update' --m
.EXAMPLE
.\deploy-server.ps1 --Quiet
#>
#Requires -Version 7.2
@@ -82,16 +85,27 @@ param(
[Alias('m')]
[switch] $MandatoryUpdate,
# PowerShell advanced scripts do not bind GNU-style double-dash switches. Accept
# --m explicitly as the sole positional argument so it can still sit at the end.
[Parameter()]
[switch] $Quiet,
# PowerShell advanced scripts do not bind GNU-style double-dash switches by name.
# Accept the two documented flags in either positional order instead.
[Parameter(Position = 0)]
[ValidateSet('--m')]
[string] $MandatoryFlag
[string] $TrailingFlag0,
[Parameter(Position = 1)]
[string] $TrailingFlag1
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$mandatoryRelease = $MandatoryUpdate -or $MandatoryFlag -eq '--m'
$trailingFlags = @($TrailingFlag0, $TrailingFlag1) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
$unknownFlags = @($trailingFlags | Where-Object { $_ -notin @('--m', '--Quiet', '--quiet') })
if ($unknownFlags.Count -gt 0) {
throw "Unknown deployment option: $($unknownFlags -join ', ')"
}
$mandatoryRelease = $MandatoryUpdate -or $trailingFlags -contains '--m'
$quietDeployment = $Quiet -or $trailingFlags -contains '--Quiet' -or $trailingFlags -contains '--quiet'
if ($mandatoryRelease -and $SkipAppRelease) {
throw '--m cannot be combined with -SkipAppRelease because no update would be published.'
@@ -108,6 +122,9 @@ function Write-Banner {
if ($mandatoryRelease) {
Write-Host '│ Update mandatory (viewers cannot skip it)' -ForegroundColor Yellow
}
if ($quietDeployment) {
Write-Host '│ Notice quiet (no advance television announcement)' -ForegroundColor DarkGray
}
Write-Host '╰─' -ForegroundColor Magenta
Write-Host ''
}
@@ -534,6 +551,7 @@ destination='__DESTINATION__'
health_timeout=__HEALTH_TIMEOUT__
publish_release=__PUBLISH_RELEASE__
mandatory_update=__MANDATORY_UPDATE__
quiet_deployment=__QUIET_DEPLOYMENT__
parent=$(dirname "$destination")
staging="${destination}.new.$$"
backup="${destination}.previous.$$"
@@ -750,7 +768,9 @@ step '[remote 4/10] Telling the televisions'
#
# Entirely best-effort: a deployment must never fail over a banner, and a first
# deployment (or one onto a host with no curl) has nothing to announce with.
if [ -z "$previous_admin_token" ]; then
if [ "$quiet_deployment" -eq 1 ]; then
detail 'Quiet deployment; skipping the television announcement'
elif [ -z "$previous_admin_token" ]; then
detail 'No previous release to announce from; skipping'
elif ! command -v curl >/dev/null 2>&1; then
detail 'curl is unavailable on the NAS; skipping the announcement'
@@ -895,6 +915,10 @@ success 'Memby gateway: https://mserver.sublogue.com'
'__MANDATORY_UPDATE__',
$(if ($mandatoryRelease) { '1' } else { '0' })
)
$remoteCommand = $remoteCommand.Replace(
'__QUIET_DEPLOYMENT__',
$(if ($quietDeployment) { '1' } else { '0' })
)
# This file is edited on Windows, so the here-string above arrives with whatever line
# endings it was saved with. A remote shell reads a trailing carriage return as part
# of the token — 'set -eu\r' fails with "illegal option" before anything runs — so the