mirror of
https://github.com/supabase/supabase.git
synced 2026-09-09 19:42:46 +08:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## Problem The Docs E2E link checker found broken links throughout docs, starting with `phone-login.mdx` pointing to `/docs/guides/cli/config` (404). Old links like `/docs/guides/cli/config` still work on the live site because `supabase.com` has redirects set up for them, but these links break on the docs preview site, which is what the E2E check tests against. These issues look clean on the live site, and I didn't catch them in my first pass because I was testing production instead of the preview. The E2E check only tests the ~20 pages a given PR happens to touch, so fixing the pages it flagged kept exposing more of the same problem one page at a time as each fix pulled in a new file. To stop chasing this incrementally, I cross-referenced every `/docs/guides/*` and `/docs/reference/*` redirect source in `apps/www/lib/redirects.js` against actual usage across all of `apps/docs`, and verified each candidate against the live preview. ## Solution Rather than updating the Docs E2E link checker, this PR resolves the links. **Why:** we own these docs, so keeping the links clean without redirects is keeping the house maintained. See [Broken Window Theory](https://blog.codinghorror.com/the-broken-window-theory/). Updated every link still using an old path to point straight at the current page instead of relying on a redirect. This covers old links like: - `/docs/guides/cli/config` → `/docs/guides/local-development/cli/config` - `/docs/guides/cli/getting-started` → `/docs/guides/local-development/cli/getting-started` - `/docs/guides/cli/local-development` → `/docs/guides/local-development/database-migrations` - `/docs/guides/cli/managing-environments` → `/docs/guides/deployment/managing-environments` - `/docs/guides/cli/seeding-your-database` → `/docs/guides/local-development/seeding-your-database` - bare `/docs/guides/cli` → `/docs/guides/local-development` - `/docs/guides/platform/compute-add-ons` → `/docs/guides/platform/compute-and-disk` - `/docs/guides/platform/shared-responsibility-model` → `/docs/guides/deployment/shared-responsibility-model` - `/docs/guides/database` → `/docs/guides/database/overview` - `/docs/reference/javascript`, `/docs/reference/dart`, `/docs/reference/kotlin`, `/docs/reference/python`, `/docs/reference/csharp` → their `/introduction` pages (the redirect's own destination, `/start`, turned out to be dead even on production — a separate bug in `redirects.js` I didn't touch here) - and about 35 more of the same pattern, listed in the commit messages Also fixed a handful of dead heading anchors found along the way (links that resolve to the right page but point at a `#section` that got renamed or moved), including the original `#bigquery` anchor and a few in `connecting-to-postgres.mdx` where content moved to its own dedicated page. Left alone on purpose: - `content/guides/cli.mdx` — this page has no route in the docs app at all (no `app/guides/cli/` directory), so it 404s even in production before the `www` redirect ever fires. Fixing its internal link wouldn't change that; it needs an actual routing/content decision, not a link fix. - A few candidates that already resolve fine as-is (`pg_partman`, bare `/docs/reference/api`, bare `/docs/reference/cli`) — confirmed via curl, left untouched. ## Manual testing 1. Confirmed every new link target actually exists by checking the destination file/page and matching heading anchors. 2. Cross-referenced every `/docs/guides/*` and `/docs/reference/*` redirect source in `apps/www/lib/redirects.js` against real usage in `apps/docs`, and curl-verified each old path (404) and new path (200) against the live PR preview before fixing it. 3. Ran the Docs E2E link checker locally against changed pages. 4. Spot-checked the original broken link from CI (`/docs/guides/cli/config`) to confirm it now points to a working page.
246 lines
5.8 KiB
Plaintext
246 lines
5.8 KiB
Plaintext
---
|
||
id: 'functions-deploy'
|
||
title: 'Deploy to Production'
|
||
description: 'Deploy your Edge Functions to your remote Supabase Project.'
|
||
subtitle: 'Deploy your Edge Functions to your remote Supabase Project.'
|
||
tocVideo: '5OWH9c4u68M'
|
||
---
|
||
|
||
Once you have developed your Edge Functions locally, you can deploy them to your Supabase project.
|
||
|
||
<Admonition type="note">
|
||
|
||
Before getting started, make sure you have the Supabase CLI installed. Check out the CLI installation guide for installation methods and troubleshooting.
|
||
|
||
</Admonition>
|
||
|
||
---
|
||
|
||
## Step 1: Authenticate
|
||
|
||
Log in to the Supabase CLI if you haven't already:
|
||
|
||
```bash
|
||
supabase login
|
||
```
|
||
|
||
---
|
||
|
||
## Step 2: Connect your project
|
||
|
||
Get the project ID associated with your function:
|
||
|
||
```bash
|
||
supabase projects list
|
||
```
|
||
|
||
<Admonition type="note" title="Need a new project?">
|
||
|
||
If you haven't yet created a Supabase project, you can do so by visiting [database.new](https://database.new).
|
||
|
||
</Admonition>
|
||
|
||
[Link](/docs/reference/cli/usage#supabase-link) your local project to your remote Supabase project using the ID you retrieved:
|
||
|
||
```bash
|
||
supabase link --project-ref your-project-id
|
||
```
|
||
|
||
Now you should have your local development environment connected to your production project.
|
||
|
||
---
|
||
|
||
## Step 3: Deploy Functions
|
||
|
||
You can deploy all edge functions within the `functions` folder with a single command:
|
||
|
||
```bash
|
||
supabase functions deploy
|
||
```
|
||
|
||
Or deploy individual Edge Functions by specifying the function name:
|
||
|
||
```bash
|
||
supabase functions deploy hello-world
|
||
```
|
||
|
||
## Step 4: Verify successful deployment
|
||
|
||
🎉 Your function is now live!
|
||
|
||
When the deployment is successful, your function is automatically distributed to edge locations worldwide. Your edge functions is now running globally at `https://[YOUR_PROJECT_ID].supabase.co/functions/v1/hello-world.`
|
||
|
||
---
|
||
|
||
## Step 5: Test your live function
|
||
|
||
You can now invoke your Edge Function using one of the project's `PUBLISHABLE_KEYS`, which can be found in the [API settings](/dashboard/project/_/settings/api) of the Supabase Dashboard. You can invoke it from within your app:
|
||
|
||
<$CodeTabs>
|
||
|
||
```bash name=cURL
|
||
curl --request POST 'https://<project_id>.supabase.co/functions/v1/hello-world' \
|
||
--header 'apikey: PUBLISHABLE_KEY' \
|
||
--header 'Content-Type: application/json' \
|
||
--data '{ "name":"Functions" }'
|
||
```
|
||
|
||
```js name=JavaScript
|
||
import { createClient } from '@supabase/supabase-js'
|
||
|
||
// Create a single supabase client for interacting with your database
|
||
const supabase = createClient('https://xyzcompany.supabase.co', 'sb_publishable_...')
|
||
|
||
const { data, error } = await supabase.functions.invoke('hello-world', {
|
||
body: { name: 'Functions' },
|
||
})
|
||
```
|
||
|
||
</$CodeTabs>
|
||
|
||
<Admonition type="note">
|
||
|
||
Note that the `SUPABASE_PUBLISHABLE_KEYS` is different in development and production. To get a publishable key, you can find it in your Supabase dashboard under Settings > API.
|
||
|
||
</Admonition>
|
||
|
||
You should now see the expected response:
|
||
|
||
```json
|
||
{ "message": "Hello Production!" }
|
||
```
|
||
|
||
<Admonition type="note">
|
||
|
||
You can also test the function through the Dashboard. To see how that works, check out the [Dashboard Quickstart guide](/docs/guides/functions/quickstart-dashboard).
|
||
|
||
</Admonition>
|
||
|
||
---
|
||
|
||
## CI/CD deployment
|
||
|
||
You can use popular CI / CD tools like GitHub Actions, Bitbucket, and GitLab CI to automate Edge Function deployments.
|
||
|
||
### GitHub Actions
|
||
|
||
You can use the official [`setup-cli` GitHub Action](https://github.com/marketplace/actions/supabase-cli-action) to run Supabase CLI commands in your GitHub Actions.
|
||
|
||
The following GitHub Action deploys all Edge Functions any time code is merged into the `main` branch:
|
||
|
||
```yaml
|
||
name: Deploy Function
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
workflow_dispatch:
|
||
|
||
jobs:
|
||
deploy:
|
||
runs-on: ubuntu-latest
|
||
|
||
env:
|
||
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
|
||
PROJECT_ID: your-project-id
|
||
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- uses: supabase/setup-cli@v1
|
||
with:
|
||
version: latest
|
||
|
||
- run: supabase functions deploy --project-ref $PROJECT_ID
|
||
```
|
||
|
||
---
|
||
|
||
### GitLab CI
|
||
|
||
Here is the sample pipeline configuration to deploy via GitLab CI.
|
||
|
||
```yaml
|
||
image: node:20
|
||
|
||
# List of stages for jobs, and their order of execution
|
||
stages:
|
||
- setup
|
||
- deploy
|
||
|
||
# This job runs in the setup stage, which runs first.
|
||
setup-npm:
|
||
stage: setup
|
||
script:
|
||
- npm i supabase
|
||
cache:
|
||
paths:
|
||
- node_modules/
|
||
artifacts:
|
||
paths:
|
||
- node_modules/
|
||
|
||
# This job runs in the deploy stage, which only starts when the job in the build stage completes successfully.
|
||
deploy-function:
|
||
stage: deploy
|
||
script:
|
||
- npx supabase init
|
||
- npx supabase functions deploy --debug
|
||
services:
|
||
- docker:dind
|
||
variables:
|
||
DOCKER_HOST: tcp://docker:2375
|
||
```
|
||
|
||
---
|
||
|
||
### Bitbucket Pipelines
|
||
|
||
Here is the sample pipeline configuration to deploy via Bitbucket.
|
||
|
||
```yaml
|
||
image: node:20
|
||
|
||
pipelines:
|
||
default:
|
||
- step:
|
||
name: Setup
|
||
caches:
|
||
- node
|
||
script:
|
||
- npm i supabase
|
||
- parallel:
|
||
- step:
|
||
name: Functions Deploy
|
||
script:
|
||
- npx supabase init
|
||
- npx supabase functions deploy --debug
|
||
services:
|
||
- docker
|
||
```
|
||
|
||
---
|
||
|
||
### Function configuration
|
||
|
||
Individual function configuration like [JWT verification](/docs/guides/local-development/cli/config#functions.function_name.verify_jwt) and [import map location](/docs/guides/local-development/cli/config#functions.function_name.import_map) can be set via the `config.toml` file.
|
||
|
||
```toml
|
||
[functions.hello-world]
|
||
verify_jwt = false
|
||
```
|
||
|
||
This ensures your function configurations are consistent across all environments and deployments.
|
||
|
||
---
|
||
|
||
### Example
|
||
|
||
This example shows a GitHub Actions workflow that deploys all Edge Functions when code is merged into the `main` branch.
|
||
|
||
<$CodeSample
|
||
meta="deploy.yaml"
|
||
path="/edge-functions/.github/workflows/deploy.yaml"
|
||
/>
|