diff --git a/.github/scripts/deploy-vercel.ps1 b/.github/scripts/deploy-vercel.ps1 index bba8cd8..e89ab1d 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), ALIAS_PREVIEW, BUILD_COMMIT, VERCEL_TOKEN +# EVENT_NAME, GIT_REF, IN_TARGET (blank = preview), SLOT_NUMBER, BUILD_COMMIT, VERCEL_TOKEN Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' @@ -15,11 +15,14 @@ $PSNativeCommandUseErrorActionPreference = $true Copy-Item infra/vercel/vercel.json build/web/vercel.json -Force npm i -g vercel@latest -# Target is STATED, not inferred from the ref. It used to be "main means --prod", -# which made a dispatch the wrong branch away from silently publishing to -# maze.ryankelly.dev -- an unacceptable footgun now that agents dispatch this -# workflow to get preview URLs (see docs/BUILD_VERIFICATION.md). -$target = if ($env:EVENT_NAME -eq 'push') { 'production' } +# Determine if this deploy targets a preview slot (slot/1..3) +$slot = if ($env:GIT_REF -match '^refs/heads/slot/([0-9]+)$') { $Matches[1] } + elseif (![string]::IsNullOrWhiteSpace($env:SLOT_NUMBER)) { $env:SLOT_NUMBER } + else { $null } + +# Target is STATED, not inferred from the ref. +$target = if ($env:EVENT_NAME -eq 'push' -and $env:GIT_REF -eq 'refs/heads/main') { 'production' } + elseif ($slot) { 'slot' } elseif ([string]::IsNullOrWhiteSpace($env:IN_TARGET)) { 'preview' } else { $env:IN_TARGET } @@ -33,15 +36,11 @@ 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" +# Alias preview slot if slot is specified (e.g. p1.maze.ryankelly.dev) +if ($slot) { + $aliasDomain = "p$slot.maze.ryankelly.dev" + vercel alias set $url $aliasDomain --token=$env:VERCEL_TOKEN + Write-Host "DEPLOY_ALIAS=https://$aliasDomain" } "url=$url" >> $env:GITHUB_OUTPUT diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b50cac..2f331cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,9 @@ jobs: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Verify no banned scripts (.sh / .ps1) + uses: ls-lint/action@a87c5eb4fb26d7af1bd0adba203dd1e76f7e94eb # v2.3.2 + - name: Set up .NET 9 SDK uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 with: @@ -57,6 +60,9 @@ jobs: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Verify no banned scripts (.sh / .ps1) + uses: ls-lint/action@a87c5eb4fb26d7af1bd0adba203dd1e76f7e94eb # v2.3.2 + - name: Set up .NET 9 SDK uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 with: diff --git a/.github/workflows/web-export.yml b/.github/workflows/web-export.yml index f189c23..454ee93 100644 --- a/.github/workflows/web-export.yml +++ b/.github/workflows/web-export.yml @@ -22,7 +22,7 @@ name: Web Export & Deploy on: push: - branches: [main] + branches: [main, "slot/*"] paths: - "scripts/**" - "scenes/**" @@ -47,6 +47,12 @@ on: default: "preview" type: choice options: ["preview", "production"] + slot: + description: "Preview slot (1..3) to alias this deployment (e.g. 1 -> p1.maze.ryankelly.dev)" + required: false + default: "" + type: choice + options: ["", "1", "2", "3"] godot_fork_tag: description: "Override patched-editor release tag (blank = .github/web-toolchain.env)" required: false @@ -55,11 +61,6 @@ 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] @@ -111,7 +112,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 }} + SLOT_NUMBER: ${{ github.event.inputs.slot }} BUILD_COMMIT: ${{ steps.export.outputs.build_commit }} run: '& "$env:GITHUB_WORKSPACE/.github/scripts/deploy-vercel.ps1"' @@ -261,7 +262,7 @@ jobs: # 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" + SLOT_NUMBER: "" EVENT_NAME: ${{ github.event_name }} GIT_REF: ${{ github.ref }} BUILD_COMMIT: ${{ steps.export.outputs.build_commit }} diff --git a/.ls-lint.yml b/.ls-lint.yml new file mode 100644 index 0000000..4c73a1a --- /dev/null +++ b/.ls-lint.yml @@ -0,0 +1,31 @@ +# .ls-lint.yml +# Estate-wide ban on shell (.sh, .bash, .zsh) and PowerShell (.ps1, .psm1) scripts. +# Exceptions must be explicitly listed in the `ignore:` section below. + +ls: + .sh: exists:0 + .bash: exists:0 + .zsh: exists:0 + .ps1: exists:0 + .psm1: exists:0 + "**": + .sh: exists:0 + .bash: exists:0 + .zsh: exists:0 + .ps1: exists:0 + .psm1: exists:0 + +ignore: + - .git + - .venv + - node_modules + - temp + - .temp + - .worktrees + - bin + - obj + - dist + - build + # Explicit repository exceptions: + - .github/actions/export-web/scripts/** + - .github/scripts/**