diff --git a/.github/scripts/deploy-vercel.ps1 b/.github/scripts/deploy-vercel.ps1 index da33985..bba8cd8 100644 --- a/.github/scripts/deploy-vercel.ps1 +++ b/.github/scripts/deploy-vercel.ps1 @@ -6,7 +6,7 @@ # docs/WEB_EXPORT.md. # # Inputs (environment): -# EVENT_NAME, GIT_REF, IN_TARGET (blank = preview), BUILD_COMMIT, VERCEL_TOKEN +# EVENT_NAME, GIT_REF, IN_TARGET (blank = preview), ALIAS_PREVIEW, BUILD_COMMIT, VERCEL_TOKEN Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' @@ -33,6 +33,17 @@ if ($target -eq 'production') { $url = (vercel deploy build/web --yes --token=$env:VERCEL_TOKEN) | Select-Object -Last 1 } +# ALIAS_PREVIEW=true pins this deploy to the stable bisect/inspection URL +# preview-maze.ryankelly.dev. Preview-only by design: production already has its own +# alias, and pinning a prod deploy here would silently repurpose the bisect URL. +if ($env:ALIAS_PREVIEW -eq 'true') { + if ($target -ne 'preview') { + throw "alias_preview=true is only valid with deploy_target=preview (got $target)." + } + vercel alias set $url preview-maze.ryankelly.dev --token=$env:VERCEL_TOKEN + Write-Host "DEPLOY_ALIAS=https://preview-maze.ryankelly.dev" +} + "url=$url" >> $env:GITHUB_OUTPUT "target=$target" >> $env:GITHUB_OUTPUT diff --git a/.github/workflows/web-export.yml b/.github/workflows/web-export.yml index 40114fc..0045acc 100644 --- a/.github/workflows/web-export.yml +++ b/.github/workflows/web-export.yml @@ -55,6 +55,11 @@ on: description: "Override export-template folder name (blank = .github/web-toolchain.env)" required: false default: "" + alias_preview: + description: "Alias this deploy to preview-maze.ryankelly.dev (for bisecting old commits without touching prod)" + type: boolean + required: false + default: false issue_comment: types: [created] @@ -106,6 +111,7 @@ jobs: EVENT_NAME: ${{ github.event_name }} GIT_REF: ${{ github.ref }} IN_TARGET: ${{ github.event.inputs.deploy_target }} + ALIAS_PREVIEW: ${{ github.event.inputs.alias_preview }} BUILD_COMMIT: ${{ steps.export.outputs.build_commit }} run: '& "$env:GITHUB_WORKSPACE/.github/scripts/deploy-vercel.ps1"' @@ -252,7 +258,10 @@ jobs: # Same script as the production job. IN_TARGET is pinned to preview rather than left # unset: a /preview must never be able to reach production, and stating it means the # script's behaviour does not depend on how PowerShell reads an absent env var. + # ALIAS_PREVIEW likewise: a /preview gets its own throwaway URL and must not + # commandeer the stable preview-maze.ryankelly.dev bisect alias. IN_TARGET: "preview" + ALIAS_PREVIEW: "false" EVENT_NAME: ${{ github.event_name }} GIT_REF: ${{ github.ref }} BUILD_COMMIT: ${{ steps.export.outputs.build_commit }}