teqo-backup/.github/workflows/vercel-promote.yml
Cursor Agent fded303fe6
fix(ci): stop trusting GET /v13 alias for production domain ownership
CI short-circuited "already aliased" when v13 listed pt.jorgesolla.com.br
on a fresh --prod deploy while the domain still pointed at an older
Current. Verify only via GET /v2/.../aliases and /v4/aliases?domain=.
Also drop invalid --yes on vercel alias set (CLI 55).
2026-08-01 16:12:30 +00:00

72 lines
2.7 KiB
YAML

# Promote a READY production deployment to custom domains (no rebuild).
# Use when `vercel deploy --prod` staged a deployment but left pt.jorgesolla.com.br
# on an older Current (Auto-assign Custom Production Domains OFF).
name: Vercel promote production
on:
workflow_dispatch:
inputs:
deployment:
description: 'Deployment URL or id (empty = latest READY production)'
required: false
type: string
default: ''
permissions:
contents: read
jobs:
promote:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
package-manager-cache: false
- name: Require Vercel credentials
run: |
set -euo pipefail
missing=()
[ -z "${VERCEL_TOKEN:-}" ] && missing+=(VERCEL_TOKEN)
[ -z "${VERCEL_ORG_ID:-}" ] && missing+=(VERCEL_ORG_ID)
[ -z "${VERCEL_PROJECT_ID:-}" ] && missing+=(VERCEL_PROJECT_ID)
if [ "${#missing[@]}" -gt 0 ]; then
echo "::error::Missing secrets: ${missing[*]}"
exit 1
fi
- name: Install Vercel CLI
run: npm install --global vercel@55
- name: Promote to custom production domain
env:
DEPLOYMENT_REF: ${{ inputs.deployment }}
run: |
set -euo pipefail
if [ -n "${DEPLOYMENT_REF:-}" ]; then
ref="$DEPLOYMENT_REF"
else
ref=$(node --input-type=module -e '
import { fetchLatestProductionReadyDeployment } from "./scripts/lib/vercel-production-alias.mjs";
const d = await fetchLatestProductionReadyDeployment({
token: process.env.VERCEL_TOKEN,
projectId: process.env.VERCEL_PROJECT_ID,
teamId: process.env.VERCEL_ORG_ID,
});
if (!d) {
console.error("no READY production deployment");
process.exit(1);
}
process.stdout.write(d.url ? `https://${d.url}` : d.id);
')
echo "Latest READY production: $ref"
fi
node scripts/vercel-ensure-production-alias.mjs "$ref"
# Docs: when Auto-assign is/was OFF, prefer `vercel promote` then `alias set`.
vercel promote "$ref" --token="$VERCEL_TOKEN" --scope="$VERCEL_ORG_ID" || true
# `--yes` is only valid for `alias rm`, not `alias set` (CLI 55).
vercel alias set "$ref" pt.jorgesolla.com.br --token="$VERCEL_TOKEN" --scope="$VERCEL_ORG_ID"