# Set Up GitHub Actions CI for a Supabase Project

Yes. An agent adds a workflow that runs a local Supabase, applies your migrations from scratch, lints the database, checks generated types and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-github-actions-ci/supabase/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads both halves of the repository. In a template like Razikus/supabase-nextjs-template the database lives in `supabase/`: `config.toml` names the project `sasstemplate`, Postgres major version 15, the API on port 54321 and the database on 54322, `site_url` `http://localhost:3000` with matching `additional_redirect_urls`, and a `[db.seed]` block that is enabled and points at `./seed.sql`, a file that is not in the repository. Four migrations follow: one creates an `authenticative` schema with an `is_user_authenticated()` SQL function, `SECURITY DEFINER`, that reads the `aal` claim from `auth.jwt()` against verified rows in `auth.mfa_factors`; one creates a private `files` storage bucket; one adds four policies on `storage.objects` that scope each user to a `<uid>/` prefix and require that MFA check; and one creates `public.todo_list` with row level security enabled, an `owner` foreign key to `auth.users` with cascading delete, grants to `anon` and `authenticated`, and an `Owner can do everything` policy. A `migrations_for_old/` directory holds the pre-rename versions the README explains.

The app is `nextjs/`: Next.js 15 with React 19, `@supabase/ssr` and `@supabase/supabase-js`, Paddle for billing, a `yarn.lock` at lockfile v1, and scripts `dev`, `build`, `start` and `lint`, the last through `eslint.config.mjs` extending `next/core-web-vitals` and `next/typescript`. `src/lib/types.ts` is a `supabase gen types` output, with the `Database` type and a `__InternalSupabase.PostgrestVersion` marker. `.env.template` lists `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `PRIVATE_SUPABASE_SERVICE_KEY` and a dozen `NEXT_PUBLIC_*` product settings. There are no tests and no workflows; `.github/` holds only `FUNDING.yml`. The README deploys by hand with `npx supabase link`, `config push` and `migrations up --linked`, then Vercel.

The agent writes `.github/workflows/ci.yml` with two jobs. `database` installs the CLI with `supabase/setup-cli`, runs `supabase db start`, which on a GitHub runner has Docker available, then `supabase db reset` to apply the four migrations onto an empty database in order, which is the check that a migration written against a live project still runs from nothing. `supabase db lint` runs `plpgsql_check` over functions such as `is_user_authenticated`. Then `supabase gen types typescript --local > nextjs/src/lib/types.ts` followed by `git diff --exit-code`, so a migration that changes `todo_list` without regenerating the types fails the job. `web` runs on the Node version Next.js 15 supports with the yarn cache, `yarn install --frozen-lockfile`, `yarn lint` and `yarn build`, with `NEXT_PUBLIC_SUPABASE_URL` and the anon key set to the local stack's values from `supabase status -o env`, so the build has what the pages read without a real project's keys in CI.

The seed is the one thing the agent must decide. In the sandbox, which has no Docker, it installs `docker.io`, starts `dockerd`, runs `supabase db start` and `db reset`, and sees what the CLI does when `sql_paths` names a file that does not exist; it then either adds an empty `supabase/seed.sql` with a comment or sets `enabled = false`, and says which in the pull request. It runs `db lint`, the types diff, `yarn lint` and `yarn build` the same way before writing the YAML, so every step in the workflow has passed once.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add GitHub Actions CI to this Supabase and Next.js repository. Read supabase/config.toml, every file under supabase/migrations, the Next.js package.json, lock file, eslint config and .env.template, and the README's deployment steps first. Write .github/workflows/ci.yml with two jobs. The database job installs the Supabase CLI, starts the local stack, resets the database so every migration applies from scratch, runs supabase db lint, regenerates the TypeScript types to the file the app already keeps and fails if they differ from the committed file. The web job installs the app's dependencies from its lock file, lints and builds it with the local stack's URL and anon key as environment variables. Run every step yourself first; if the seed configuration names a file that does not exist, resolve it in the least surprising way and explain the choice. Open a pull request that lists each check and its output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with `.github/workflows/ci.yml`, either a new empty `supabase/seed.sql` or a one-line change to `config.toml`, and, if the committed `nextjs/src/lib/types.ts` was already out of date with the migrations, a regenerated copy of that file with the diff explained. No migration, policy or application component changes.

The description walks the two jobs: the `supabase db reset` output listing the four migrations applied, the `db lint` result, whether the types diff was clean, and the `yarn lint` and `yarn build` summaries with the route list Next.js prints. It says which Node version the web job uses and why. The complete transcript, including the Docker install the sandbox needed, is at `GET /o/{org}/sessions/{id}/messages`.

The workflow runs on the pull request itself, so a reviewer looks at the two jobs on the checks tab first, then reads the seed decision and confirms the environment variables the build received are the local stack's and not a project's secrets. A follow-up on the same session can add `supabase test db` with a first pgTAP test for the `todo_list` policy.

## Run it on every terminal hand-off

A founder who has been applying migrations by hand with `migrations up --linked` starts this from the terminal with this body and goes back to the feature they were building. The run reads the real `config.toml`, migrations and app manifest, so the jobs it writes use this project's Postgres version, lock file and types path rather than a generic template.

Send a `request_id`, a UUID, with the body so a retried start returns the run it already began. The pull request link is on the run's `GET /o/{org}/sessions/{id}` answer once it is open, and a key with a `webhook_url` hears `run.completed` when the turn ends.

## Why run it on Rush?

A Supabase CI job is worth writing precisely because the local stack is heavy: a Postgres, an auth server and storage in containers, a CLI with its own opinions about seeds and shadow databases. Getting that right by trial and error on a laptop is a slow afternoon. The agent does the trial and error in a sandbox, including installing Docker and bringing the stack up, and the workflow that reaches the pull request has already run end to end.

The pull request carries the output of each step and the run keeps the full transcript, so the claim that all four migrations apply from scratch is a log, not a sentence. Several Supabase projects can get the same treatment at once, each in its own sandbox.

## Frequently asked questions

### Does CI need my project's keys?

No. The database job runs a local stack on the runner, and the web job builds against that stack's URL and anon key from `supabase status -o env`. The service role key and your hosted project are never involved; deploys stay as the README describes.

### What does the types check catch?

A migration that changes a table, column or function without `nextjs/src/lib/types.ts` being regenerated. The job regenerates the file from the local database and fails on any diff, so the `Database` type the app compiles against always matches the migrations.

### Why reset rather than just start?

`supabase db start` brings the stack up; `supabase db reset` drops and recreates the database, applies every migration in order from empty and runs the seed. That is the sequence a new environment or a fresh developer machine goes through, and it is what catches a migration that only worked because of state on the live project.

### What about the missing seed.sql?

`config.toml` enables seeding and points at `./seed.sql`, which is not in the repository. The agent sees how the CLI handles that in the sandbox and either adds an empty, commented `seed.sql` so the path is honest or turns seeding off, and the pull request says which and why.

### Can it run pgTAP tests too?

Yes, once there are some. `supabase test db` runs SQL files under `supabase/tests/`. The pull request leaves that step out because the directory does not exist yet, and a follow-up can add a first test for the `todo_list` owner policy.

## More Supabase jobs

- [Add Magic Link Sign-In to a Supabase App](https://getrush.ai/run/add-magic-link-auth/supabase/)
- [Add a Password Policy to a Supabase App](https://getrush.ai/run/add-password-policy/supabase/)
- [Add Realtime Updates to a Supabase Todo List](https://getrush.ai/run/add-realtime-updates/supabase/)

## The same job on other stacks

- [Set Up GitHub Actions CI for a SvelteKit App](https://getrush.ai/run/add-github-actions-ci/sveltekit/)
- [Set Up GitHub Actions CI for a Temporal TypeScript Project](https://getrush.ai/run/add-github-actions-ci/temporal/)
- [Set Up GitHub Actions CI for a Terraform Repository](https://getrush.ai/run/add-github-actions-ci/terraform/)

## Keep reading

- [What an agent can do in Supabase itself, once you connect it](https://getrush.ai/integrations/supabase/)
- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
