# Ship on merge (/en/docs/deployment/ship-on-merge)

① Live → ② Accounts work → **③ Merge = deployed** → ④ Features → ⑤ Taking payments

Your app is live and accounts work. This page connects your repository to
Supabase and to your host, so a merge to `main` starts database and host deployments. Check both results.

**Give your agent this prompt:**

```text interactive=true
Prepare automatic deployment for my app on <host>.
Follow https://coremvp.com/en/docs/deployment/ship-on-merge.md and its prerequisites.
Finish when both provider checks pass on the merged commit and ./coremvp prod e2e smoke https://<app-domain> passes; ask me before authorizing or connecting the repository to a provider, pushing a branch that triggers a deployment (including Vercel Preview), merging, deploying or changing production.
Report what changed, the check results and anything you could not run.
```

**You'll need**

Your own private GitHub repository for the app, with CoreMVP kept as the
`upstream` remote (see [After purchase](/en/docs/getting-started/after-purchase)).
Install and authenticate the [GitHub CLI](https://cli.github.com/), and start
from a clean, current `main` branch in your app repository.
Supabase's GitHub integration works on every Supabase plan. On Vercel, a
private repository owned by a GitHub organization needs Vercel Pro. On
Cloudflare, Workers Builds includes 3,000 build minutes a month on the Free
plan.

## What happens on each merge

GitHub holds no keys. Supabase and your host each watch `main`:

1. **Supabase** applies new migrations from `supabase/migrations` to your
   production database.
2. **Your host** builds and deploys the new code with the settings you already
   saved there.

Your app's secrets stay where you saved them: in your Vercel project, or on
your Cloudflare Worker.

These run independently, so either can finish first. Write each change so
the live code keeps working while the other one catches up; see
[Ship a change](/en/docs/deployment/after-launch/ship-a-change#add-first-use-later).

### 1. Connect Supabase

In your production Supabase project, open **Project Settings →
Integrations**. Under **GitHub**, select **Connect GitHub**. The first
time, GitHub asks you to install the Supabase app: choose **Only select
repositories**, pick your app repository, then **Install & Authorize**.
Back in Supabase, choose your app repository.

| Setting                | Value                                                 |
| ---------------------- | ----------------------------------------------------- |
| Working directory      | `.` (the `supabase` folder is at the repository root) |
| Deploy to production   | On                                                    |
| Production branch name | `main`                                                |
| Automatic branching    | Off                                                   |

Select **Enable integration**.

### 2. Connect your host

**Vercel:**

```bash
bunx vercel git connect "$(git remote get-url origin)"
```

Naming `origin` connects your own repository, not the CoreMVP `upstream`.

Vercel deploys every push to `main` to Production, with the settings saved
in your project. Other branches get preview deployments; you can ignore
them.

**Cloudflare:**

In Cloudflare, open **Workers & Pages**, select your Worker, then
**Settings → Build**. Select **Connect** and choose your app repository.

| Setting                        | Value                                     |
| ------------------------------ | ----------------------------------------- |
| Build command                  | `bun run build:cloudflare`                |
| Deploy command, Next.js        | `bunx --no-install cf deploy --prebuilt`  |
| Deploy command, TanStack Start | `bunx cf@1.0.0-beta.14 deploy --prebuilt` |

Under **Build variables**, add `CLOUDFLARE_ACCOUNT_ID` and every
`NEXT_PUBLIC_` value plus `CLOUDFLARE_HYPERDRIVE_ID` from `.env.cloudflare`.
The build runs on Cloudflare, so it needs them; they are public, not
secrets. When a later page adds a `NEXT_PUBLIC_` value, add it here too.

Under **Branch control**, keep `main` as the production branch and clear
**Enable Preview Builds**.

Your server secrets stay on the Worker from your last `cf deploy`; a build
deploy keeps them.

### 3. Merge a small change

```bash
git switch -c try-ship-on-merge
echo "" >> README.md
git add README.md
git commit -m "Try ship on merge"
```

Confirm that a Preview deployment is OK before pushing if your host deploys
this branch. Push and open the pull request:

```bash
git push -u origin try-ship-on-merge
gh pr create --fill
```

Review the pull request and confirm the production deployment before merging:

```bash
gh pr merge --merge
```

## Check it works

Open the merged commit on GitHub. It shows a check from Supabase and one from
Vercel or Cloudflare, both passing. Your host shows a new production
deployment of that commit, and you ran no deploy command.

Then check the live app answers:

```bash interactive=true
./coremvp prod e2e smoke https://<app-domain>
```

## When something fails

| Failed                      | What changed                                                                                          | What to do                                                                                                                   |
| --------------------------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Supabase, first migration   | The new code may be live; the database is unchanged                                                   | Fix the migration and merge again. If the live app breaks, [roll back](/en/docs/deployment/after-launch/roll-back) the host. |
| Supabase, a later migration | The migrations before it are applied; the failed one is not, because each runs in its own transaction | Fix the failed migration file itself and merge again. Never edit a migration that is already applied.                        |
| Host build or deploy        | The database may be ahead of the live code                                                            | Fix the build and merge again, or retry the deployment in your host's dashboard if the failure was temporary.                |

## What's next

- [Next: Add email](/en/docs/deployment/email): Send sign-up and billing email to any address.
