name: Deploy Supabase Edge functions

on:
  push:
    paths:
      - 'supabase/functions/**'
      - '.github/workflows/supabase.yml'
    branches:
      - main

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

env:
  SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
  SUPABASE_PROJECT_ID: ${{ vars.SUPABASE_PROJECT_ID }}

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Setup Supabase CLI
        uses: supabase/setup-cli@v1
        with:
          version: latest

      - name: Deploy supabase edge functions
        run: supabase functions deploy --project-ref "$SUPABASE_PROJECT_ID"
