Build with different enviroment variables on different preview deployments

Hey! I'm currently trying to set up some preview/staging enviroments for our project which uses sveltekit hosted on cloudflare pages and supabase as a backend. I'm trying to link up the supabase preview branches with the preview deployments on cloudflare pages. I've been able to get the connection urls and tokens generated for the preview branches on supabase in our workflow, but I'm struggling to find out how to insert those as enviroment variables on the respective cloudflare preview deployments. Basically I want each preview deployment to have a different db connection url in the enviroment variables. Does anyone know how one would do this? I assume I would have to use wrangler to build the previews?
2 Replies
Erisa
Erisa7mo ago
The short answer is that you cant. The long answer is that you would have to write a custom script on build that ingests CF_PAGES_BRANCH and modifies variables according to its contents, or drop Pages CI and write everything in your own CI/CD e.g. GH Actions.
fredviken
fredvikenOP7mo ago
Okay then I think I'll try to write my own CI/CD, thanks!
Want results from more Discord servers?
Add your server