使用 GitHub Actions 与稳定的 URL 别名,为 Vercel 项目配置暂存/生产工作流。需创建暂存环境时使用。
Stable staging URLs for Vercel projects via GitHub Actions + Vercel Alias API.
Vercel generates random URLs per deployment ( myproject-abc123.vercel.app). You want a stable staging URL that always points to the latest main deploy.
A GitHub Action that:
mainyourproject-staging.vercel.appResult: Two stable URLs per project:
yourproject-staging.vercel.app → latest main (auto-updated)yourproject.vercel.app → production (manual promote or custom domain)bash
cd your-project
vercel link --yes
cat .vercel/project.json # copy projectId
⚠️ Important: Use a permanent token from https://vercel.com/account/tokens — NOT the CLI token (those rotate automatically!).
In your repo → Settings → Secrets:
VERCEL_TOKEN — permanent API tokenVERCEL_PROJECT_ID — from step 1VERCEL_TEAM_ID — (optional, for team accounts)Copy references/github-action-template.yml to .github/workflows/staging-alias.yml.
Edit the STAGING_ALIAS variable:
yaml
STAGING_ALIAS: "yourproject-staging.vercel.app"
bash
git add .github/workflows/staging-alias.yml
git commit -m "ci: add staging alias workflow"
git push
After the action runs, https://yourproject-staging.vercel.app will point to the latest deployment.
For multiple projects sharing the same token, set VERCEL_TOKEN as an org-level secret and only vary VERCEL_PROJECT_ID per repo.
Production stays separate — either:
production branch that triggers a production aliasVERCEL_TEAM_ID — find it in Vercel dashboard URL or APISee references/github-action-template.yml for the complete, commented GitHub Action file ready to copy into your project.