← 返回
未分类 Key 中文

Vercel Staging Workflow

Set up a staging/production workflow for Vercel projects using GitHub Actions and stable URL aliases. Use when asked to create a staging environment, set up...
使用 GitHub Actions 与稳定的 URL 别名,为 Vercel 项目配置暂存/生产工作流。需创建暂存环境时使用。
danielgrobelny
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 357
下载
💾 1
安装
1
版本
#latest

概述

Vercel Staging Workflow

Stable staging URLs for Vercel projects via GitHub Actions + Vercel Alias API.

The Problem

Vercel generates random URLs per deployment (myproject-abc123.vercel.app). You want a stable staging URL that always points to the latest main deploy.

The Solution

A GitHub Action that:

  1. Triggers on push to main
  2. Waits for Vercel's Git-triggered deployment to finish
  3. Sets a stable alias: yourproject-staging.vercel.app

Result: Two stable URLs per project:

  • yourproject-staging.vercel.app → latest main (auto-updated)
  • yourproject.vercel.app → production (manual promote or custom domain)

Setup (per project)

1. Get Vercel Project ID

cd your-project
vercel link --yes
cat .vercel/project.json  # copy projectId

2. Create Permanent API Token

⚠️ Important: Use a permanent token from https://vercel.com/account/tokens — NOT the CLI token (those rotate automatically!).

3. Add GitHub Secrets

In your repo → Settings → Secrets:

  • VERCEL_TOKEN — permanent API token
  • VERCEL_PROJECT_ID — from step 1
  • VERCEL_TEAM_ID — (optional, for team accounts)

4. Add the GitHub Action

Copy references/github-action-template.yml to .github/workflows/staging-alias.yml.

Edit the STAGING_ALIAS variable:

STAGING_ALIAS: "yourproject-staging.vercel.app"

5. Push and verify

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.

Multi-Project Setup

For multiple projects sharing the same token, set VERCEL_TOKEN as an org-level secret and only vary VERCEL_PROJECT_ID per repo.

Production Deploys

Production stays separate — either:

  • Use Vercel's "Promote to Production" button
  • Set up a production branch that triggers a production alias
  • Use custom domains (always point to production)

Key Gotchas

  1. CLI tokens rotate — always use permanent API tokens from vercel.com/account/tokens
  2. Team accounts need VERCEL_TEAM_ID — find it in Vercel dashboard URL or API
  3. Wait time — the action polls for up to 3 minutes for deployment to reach READY
  4. Fallback — if exact commit not found, falls back to latest READY deployment

Full Action Template

See references/github-action-template.yml for the complete, commented GitHub Action file ready to copy into your project.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-31 11:07 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Whisper Piper Voice

danielgrobelny
在本地搭建并运行一个语音管道,将 Whisper STT(语音转文本)与 Piper TTS(文本转语音)合并为一个 HTTP 服务器,用于响应本地语音服务的搭建需求。
★ 0 📥 354

Ci Failure Fixer

danielgrobelny
监控 GitHub Actions CI 流水线,检测失败并自动修复常见问题。适用于要求监控 CI、修复构建失败、监视 GitHub Actions 等场景。
★ 0 📥 371

Revealjs Presentations

danielgrobelny
创建、编辑并部署 reveal.js 演示文稿为单个 HTML 文件,可选自定义 CSS。适用于需要制作演示文稿、幻灯片或宣传材料时使用。
★ 1 📥 667