teqo-backup/scripts/vercel-ensure-production-alias.mjs
Cursor Agent baa8f14f82
fix(ci): promote Vercel deploy to pt.jorgesolla.com.br
Disabling Git auto-deploy is correct for Actions-gated production. The
separate project toggle "Auto-assign Custom Production Domains" must stay
ON — when OFF, `vercel deploy --prod` only aliases *.vercel.app and leaves
the custom domain on an older Current (exactly what we saw after #122).

After each deploy, ensure-production-alias re-enables auto-assign if needed,
promotes the deployment, and verifies pt.jorgesolla.com.br is attached.
Also adds workflow_dispatch "Vercel promote production" for promote-without-rebuild.
2026-08-01 15:26:31 +00:00

62 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
/**
* vercel-ensure-production-alias — after `vercel deploy --prod`, make sure the
* custom production hostname (pt.jorgesolla.com.br) points at the deployment.
*
* Usage:
* node scripts/vercel-ensure-production-alias.mjs <deployment-url-or-id>
* node scripts/vercel-ensure-production-alias.mjs --latest
*
* Env: VERCEL_TOKEN, VERCEL_PROJECT_ID, VERCEL_ORG_ID
*/
import { dieWithLabel } from './lib/cli.mjs'
import {
ensureProductionCustomDomain,
fetchLatestProductionReadyDeployment,
PRODUCTION_CUSTOM_DOMAIN,
} from './lib/vercel-production-alias.mjs'
const die = dieWithLabel('vercel-ensure-production-alias')
const main = async () => {
const token = process.env.VERCEL_TOKEN
const projectId = process.env.VERCEL_PROJECT_ID
const teamId = process.env.VERCEL_ORG_ID
if (!token) die('VERCEL_TOKEN is required')
if (!projectId) die('VERCEL_PROJECT_ID is required')
if (!teamId) die('VERCEL_ORG_ID is required')
const arg = process.argv[2]
if (!arg) {
die('pass a deployment URL/id, or --latest')
}
let deploymentRef = arg
if (arg === '--latest') {
const latest = await fetchLatestProductionReadyDeployment({ token, projectId, teamId })
if (!latest) die('no READY production deployment found')
deploymentRef = latest.url ? `https://${latest.url}` : latest.id
console.log(`[vercel-ensure-production-alias] latest READY production: ${deploymentRef}`)
}
const result = await ensureProductionCustomDomain({
token,
projectId,
teamId,
deploymentRef,
expectedHost: PRODUCTION_CUSTOM_DOMAIN,
})
for (const step of result.steps) {
console.log(`[vercel-ensure-production-alias] ${step}`)
}
console.log(
`[vercel-ensure-production-alias] ok — ${PRODUCTION_CUSTOM_DOMAIN} → ${result.deployment.id}` +
(result.promoted ? ' (promoted)' : ' (already assigned)'),
)
}
main().catch((error) => {
die(error instanceof Error ? error.message : String(error))
})