Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/scripts/deploy-vercel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/web-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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"'

Expand Down Expand Up @@ -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 }}
Expand Down
Loading