Deployment Methods
Supabase Edge Functions can be deployed using:- Supabase CLI: Manual deployments from your local machine
- GitHub Actions: Automated CI/CD deployments
- Other CI/CD: GitLab CI, CircleCI, Bitbucket Pipelines, etc.
CLI Deployment
Deploy a Single Function
Deploy one function:Deploy All Functions
Deploy all functions in your project:Deploy to a Specific Project
Deploy to a specific project using the project reference:Verify Deployment
List all deployed functions:GitHub Actions Deployment
Automate deployments when you push code to GitHub.Setup
1. Generate Access Token
- Go to https://supabase.com/dashboard/account/tokens
- Click “Generate New Token”
- Give it a name like “GitHub Actions”
- Copy the token
2. Add Token to GitHub Secrets
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click “New repository secret”
- Name:
SUPABASE_ACCESS_TOKEN - Value: Paste your token
- Click “Add secret”
3. Create Workflow File
Create.github/workflows/deploy.yml:
Deploy Specific Functions
Deploy only specific functions:Deploy on Path Changes
Only deploy when function code changes:Deploy with Secrets
Set secrets during deployment:Multi-Environment Deployment
Deploy to staging and production:Configuration
Function Configuration
Configure individual functions inconfig.toml:
Configuration Options
verify_jwt
Control JWT verification:import_map
Specify custom import map location:Import Maps
Import maps let you alias module URLs for easier imports.Create Import Map
Createsupabase/functions/import_map.json:
Use Aliases
Now use short aliases in your functions:Function-Specific Import Maps
Create per-function import maps:Advanced Deployment Strategies
Blue-Green Deployment
Deploy new version alongside old version:Canary Deployment
Gradually roll out new version:- Deploy new version
- Route small percentage of traffic to new version
- Monitor metrics and errors
- Gradually increase traffic
- Complete rollout or rollback if issues found
Canary deployments require a load balancer or custom routing logic in your application.
Rolling Back
Quickly revert to previous version:Deployment Best Practices
Version Control
Always commit function code to git:Test Before Deploy
Run tests locally before deploying:Deployment Checklist
Before deploying:- Test function locally
- Set required environment variables
- Update function configuration in
config.toml - Review code changes
- Check for breaking changes
- Verify JWT settings
- Test with production-like data
Monitor Deployments
Check logs after deployment:- Increased error rates
- Performance degradation
- Unexpected behavior
CI/CD with Other Platforms
GitLab CI
Create.gitlab-ci.yml:
CircleCI
Create.circleci/config.yml:
Bitbucket Pipelines
Createbitbucket-pipelines.yml:
Troubleshooting
Deployment Fails
If deployment fails:-
Check CLI version:
-
Verify project link:
-
Check access token:
- Review function code for syntax errors
Function Not Updating
If changes don’t appear:-
Verify deployment succeeded:
- Check function version increased
- Clear browser cache if testing in browser
- Wait a few seconds for propagation
Permission Errors
If you get permission errors:- Regenerate access token with correct permissions
- Update token in secrets for CI/CD
- Verify project reference is correct
Next Steps
Environment Variables
Manage secrets and configuration
Debugging
Debug and monitor your functions
