The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add GitHub Actions deploy Edge Function example
thorwebdev07c406b623b6
diff --git a/examples/edge-functions/.github/workflows/deploy.yaml b/examples/edge-functions/.github/workflows/deploy.yamlnew file mode 100644index 00000000000..1bb40de48ef--- /dev/null+++ b/examples/edge-functions/.github/workflows/deploy.yaml@@ -0,0 +1,24 @@+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: zdtdtxajzydjqzuktnqx++ steps:+ - uses: actions/checkout@v3++ - uses: supabase/setup-cli@v1+ with:+ version: 1.0.0++ - run: supabase functions deploy github-action-deploy --project-ref $PROJECT_IDdiff --git a/examples/edge-functions/README.md b/examples/edge-functions/README.mdindex b6db1863365..efa08780dd0 100644--- a/examples/edge-functions/README.md+++ b/examples/edge-functions/README.md@@ -59,6 +59,39 @@ This example includes a create-react-app in the [`./app/`](./app/) directory whi- `npm install`- `npm start`+### Deploy via GitHub Actions++This example includes a [deploy GitHub Action](./.github/workflows/deploy.yaml) that automatically deploys your Supabase Edge Functions when pushing to or merging into the main branch.++You can use the [`setup-cli` GitHub Action](https://github.com/marketplace/actions/supabase-cli-action) to run Supabase CLI commands in your GitHub Actions, for example to deploy a Supabase Edge Function:++```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: zdtdtxajzydjqzuktnqx++ steps:+ - uses: actions/checkout@v3++ - uses: supabase/setup-cli@v1+ with:+ version: 1.0.0++ - run: supabase functions deploy your-function-name --project-ref $PROJECT_ID+```+## 👁⚡️👁\o/ That's it, you can now invoke your Supabase Function via the [`supabase-js`](https://supabase.com/docs/reference/javascript/invoke) and [`supabase-dart`](https://supabase.com/docs/reference/dart/invoke) client libraries. (More client libraries coming soon. Check the [supabase-community](https://github.com/supabase-community#client-libraries) org for details).diff --git a/examples/edge-functions/supabase/functions/github-action-deploy/README.md b/examples/edge-functions/supabase/functions/github-action-deploy/README.mdnew file mode 100644index 00000000000..01a7fd0d7d1--- /dev/null+++ b/examples/edge-functions/supabase/functions/github-action-deploy/README.md@@ -0,0 +1,32 @@+# GitHub Actions Deploy++This example includes a [deploy GitHub Action](./../../../.github/workflows/deploy.yaml) that automatically deploys your Supabase Edge Functions when pushing to or merging into the main branch.++You can use the [`setup-cli` GitHub Action](https://github.com/marketplace/actions/supabase-cli-action) to run Supabase CLI commands in your GitHub Actions, for example to deploy a Supabase Edge Function:++```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: zdtdtxajzydjqzuktnqx++ steps:+ - uses: actions/checkout@v3++ - uses: supabase/setup-cli@v1+ with:+ version: 1.0.0++ - run: supabase functions deploy github-action-deploy --project-ref $PROJECT_ID+```diff --git a/examples/edge-functions/supabase/functions/github-action-deploy/index.ts b/examples/edge-functions/supabase/functions/github-action-deploy/index.tsnew file mode 100644index 00000000000..2dc629d0cf8--- /dev/null+++ b/examples/edge-functions/supabase/functions/github-action-deploy/index.ts@@ -0,0 +1,24 @@+// Follow this setup guide to integrate the Deno language server with your editor:+// https://deno.land/manual/getting_started/setup_your_environment+// This enables autocomplete, go to definition, etc.++import { serve } from "https://deno.land/[email protected]/http/server.ts";++console.log("Hello from Functions!");++serve(async (req) => {+ const { name } = await req.json();+ const data = {+ message: `I was deployed via GitHub Actions!`,+ };++ return new Response(JSON.stringify(data), {+ headers: { "Content-Type": "application/json" },+ });+});++// To invoke:+// curl -i --location --request POST 'http://localhost:54321/functions/v1/' \+// --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs' \+// --header 'Content-Type: application/json' \+// --data '{"name":"Functions"}'