Source:
ocean/docs/SUPABASE_CICD_SETUP.md| ✏️ Edit on GitHub
Supabase CI/CD Setup Guide
This guide explains how to set up the GitHub Actions workflows for automated Supabase deployments.
Required GitHub Secrets
Add these secrets to your GitHub repository under Settings → Secrets and variables → Actions:
1. SUPABASE_ACCESS_TOKEN (Required)
Your personal Supabase access token for CLI authentication.
# Generate token at: https://supabase.com/dashboard/account/tokens
# Or use Supabase CLI:
supabase login
2. SUPABASE_DB_PASSWORD (Required)
The database password for your Supabase project.
# Find in Supabase Dashboard:
# Settings → Database → Connection string → Password
3. SUPABASE_ANON_KEY (Required)
The anonymous/public key for your Supabase project.
# Find in Supabase Dashboard:
# Settings → API → anon/public key
4. NEON_API_KEY (Optional)
API key for Neon database provisioning.
# Get from: https://console.neon.tech/app/settings/api-keys
5. STRIPE_SECRET_KEY (Optional)
Stripe secret key for billing integration.
# Get from: https://dashboard.stripe.com/apikeys
6. STRIPE_WEBHOOK_SECRET (Optional)
Stripe webhook endpoint secret.
# Get from: https://dashboard.stripe.com/webhooks
7. SLACK_WEBHOOK_CRITICAL (Optional)
Slack webhook URL for critical alerts.
Workflows
1. deploy-Supabase.yml
- Trigger: Push to main branch (when Supabase/* files change)
- Purpose: Automatically deploy migrations and Edge Functions
- Safety: Runs on every push to main
2. deploy-Supabase-production.yml
- Trigger: GitHub Release or manual workflow dispatch
- Purpose: Production deployments with extra safety checks
- Safety: Requires explicit confirmation, includes backup step
Usage
Automatic Deployments
- Make changes to Supabase files
- Push to main branch
- CI/CD automatically deploys changes
Manual Production Deployment
- Go to Actions → Deploy Supabase to Production
- Click "Run workflow"
- Type "production" to confirm
- Click "Run workflow"
Creating a Release
- Create a new GitHub release
- Production deployment automatically triggers
- Includes all safety checks and smoke tests
Monitoring Deployments
Check Deployment Status
- Go to Actions tab in GitHub
- View running/completed workflows
- Check logs for any errors
Rollback Procedures
If a deployment fails:
-
The workflow will attempt automatic rollback
-
Check Supabase Dashboard for current state
-
Manually revert if needed using:
git revert <commit>
git push origin main
Local Development
Before pushing changes:
# Test migrations locally
supabase db push --dry-run
# Test Edge Functions
supabase functions serve
# Run local tests
pnpm test
Troubleshooting
Migration Failures
- Check for SQL syntax errors
- Ensure no breaking schema changes
- Verify permissions (don't modify Supabase-owned schemas)
Edge Function Deployment Failures
- Check function has index.ts file
- Verify no import errors
- Test locally first with
supabase functions serve
Secret Issues
- Ensure all required secrets are set
- Check secret names match exactly
- Rotate tokens if authentication fails
Best Practices
- Always test locally first
- Use feature branches for development
- Create migrations carefully - they can't be easily rolled back
- Monitor deployments - check Actions tab after pushing
- Document breaking changes in pull requests
Emergency Contacts
If production deployment fails and needs immediate attention:
- Check #alerts Slack channel
- Review Supabase Dashboard logs
- Contact on-call engineer