Skip to content
Home

部署与分支

部署你的应用会让它上线并可供用户访问。大多数应用至少有两个环境:一个是面向用户的生产环境,一个或多个是供开发使用的预演或预览环境。

🌐 Deploying your app makes it live and accessible to users. Most apps have at least two environments: a production environment for users and one or more staging or preview environments for development.

Supabase 提供了适用于各种复杂程度部署工作流的灵活选项。

🌐 Supabase provides flexible options for deployment workflows of various complexity.

🌐 Recommended workflow

你可以通过 GitHub 部署你的 Supabase 项目:

🌐 You can deploy your Supabase project with GitHub:

  1. 使用 Supabase CLI 在本地开发
  2. 把更改推送到你的 GitHub 仓库
  3. 从你的 main 分支自动部署到你的 Supabase 项目

这个工作流程适用于所有计划,并且不需要分支。

🌐 This workflow works on all plans and does not require branching.

如果你开启了分支功能(在专业版计划中),你可以为拉取请求扩展这个工作流,添加预览环境。

🌐 If you have branching enabled (on the Pro Plan), you can extend this workflow with preview environments for pull requests.

环境管理 #

🌐 Environment management

你可以维护独立的开发、测试和生产环境:

🌐 You can maintain separate development, staging, and production environments:

  • 开发:使用 Supabase CLI 在本地开发
  • 暂存 / 预览(可选):使用分支为拉取请求或长期存在的暂存环境创建预览环境(专业版)
  • 生产环境:从你的 GitHub 仓库或你自己的 CI/CD 流水线部署更改

部署 #

🌐 Deployment

你可以使用以下方式来自动部署:

🌐 You can automate deployments using:

常见问题 #

🌐 Frequently asked questions

需要用 GitHub 吗? #

🌐 Is GitHub required?

不需要。建议使用 GitHub 集成,但你也可以在自己的 CI/CD 流水线中使用 Supabase CLI 部署,而无需连接 GitHub 仓库。

🌐 No. GitHub integration is recommended, but you can deploy using the Supabase CLI in your own CI/CD pipeline without connecting a GitHub repository.

你需要付费计划吗? #

🌐 Do you need a paid plan?

不。GitHub 集成和基于 CLI 的部署在所有套餐都可用。分支功能(用于拉取请求的预览环境)需要 Pro 套餐。

🌐 No. The GitHub integration and CLI-based deployments work on all plans. Branching (preview environments for pull requests) requires the Pro Plan.

部署什么? #

🌐 What gets deployed?

你在 supabase/ 目录下的数据库迁移,以及在 supabase/config.toml 中声明的 Edge 函数和存储桶。其他本地配置文件(比如 API 或身份验证设置)默认会被忽略。有关目录结构的详细信息,请参阅本地开发指南

🌐 Database migrations in your supabase/ directory, plus Edge Functions and storage buckets that are declared in supabase/config.toml. Other local configuration files (such as API or Auth settings) are ignored by default. See the local development guide for details on the directory structure.

你能用你自己的 CI/CD 流水线吗? #

🌐 Can you use your own CI/CD pipeline?

是的。你可以在任何 CI/CD 系统(GitHub Actions、GitLab CI、CircleCI 等)中使用 Supabase CLITerraform provider

🌐 Yes. You can use the Supabase CLI or the Terraform provider in any CI/CD system (GitHub Actions, GitLab CI, CircleCI, etc.).

和其他开发者合作是怎么进行的? #

🌐 How does collaboration with other developers work?

使用 Git 分支可以独立处理更改并与团队共享。当某个更改准备好时,将其合并到 main 以部署到生产环境。如果你使用的是专业版计划,你可以启用 分支 来自动为每个拉取请求创建预览环境,这样你就可以在数据库更改上线前进行查看和测试。

🌐 Use Git branches to work on changes independently and share them with your team. When a change is ready, merge it into main to deploy it to production. If you're on the Pro Plan, you can enable branching to automatically create a preview environment for each pull request, so you can review and test database changes before they go live.

什么是分支? #

🌐 What is branching?

分支会为每个拉取请求创建独立的预览环境,这样你就可以在合并前测试数据库更改。这是 Pro 计划提供的可选功能。详情请参阅分支指南

🌐 Branching creates isolated preview environments for each pull request, so you can test database changes before merging. It is an optional feature available on the Pro Plan. See the branching guide for details.

分支有什么好处? #

🌐 What advantage does branching offer?

分支功能会给每个拉取请求一个独立的 Supabase 环境,包含你数据库架构的完整副本(没有任何生产数据),这样你就可以在合并到 main 之前验证迁移并端到端测试你的应用。

🌐 Branching gives each pull request its own isolated Supabase environment with a full copy of your database schema (without any production data), so you can validate migrations and test your app end-to-end before merging to main.