3rd Party Services with Preview Branches
I'm looking for some practical advice on how I might tackle integrating 3rd party services (eg. Clerk, Stripe, etc) into branches created for Preview deployments (I'm using the Neon Vercel integration).
The problem
Branches for preview deployments have been so far great for creating preview deployments that have a copy of all my real production data. And so long as I'm only creating data within my own DB, it also works. However, when data is stored in a 3rd party provider, that data is obviously not copied. This leads to weird data mismatch issues, where I have bits of some production data but not others.
Solution?
The only reasonable solution to this I can think of is to keep staging data completely isolated from production. Since the integration automatically syncs data from the default production branch though, I'm not sure it's even possible to configure it this way via the Neon Vercel Integration. So, I believe I would need to create my own CI action to do this.
That being said, I'm open to altneratives!
13 Replies
stormy-gold•17mo ago
You can prepare a staging branch and then use that branch as the parent for preview branches.
Unfortunately the Neon integration on Vercel doesn't allow you to pick a parent branch other than the default 🤔 I'll let the engineering team know
I believe I would need to create my own CI action to do thisThis is the way right now for your use case
old-apricotOP•17mo ago
Thanks Mahmoud! And yes that would be a nice little upgrade to the Vercel integration. For now I'm creating actions based off of this guide https://neon.tech/blog/branching-with-preview-environments
Neon
A database for every preview environment using Neon, GitHub Actions...
Learn how to create a Neon branch for every preview environment using Neon, GitHub Actions, and Vercel.
stormy-gold•17mo ago
Feel free to ping me If you have any questions or run into any issues
old-apricotOP•17mo ago
Actually, there is one issue. I seem to be running into this problem: https://github.com/neondatabase/create-branch-action/issues/50
GitHub
DB URL does not contain the current database name · Issue #50 · neo...
Steps to reproduce use neondatabase/create-branch-action@v4 to create a new branch specify project_id, username, branch_name, and api_key parameters echo db_url output echo "NEON_DATABASE_URL=...
old-apricotOP•17mo ago
For now I should be able to manually replace
neondb from the db_url stringstormy-gold•17mo ago
Do you mind sharing how you're using the action?
Also, are you using the Action's latest version?
btw our Product team got back to me and specifying a parent branch other than the default branch is on our roadmap for the integration
old-apricotOP•17mo ago
Hey, yup!
stormy-gold•17mo ago
What happens when you pass the database name?
I'm guessing it's not
neondb, right?old-apricotOP•17mo ago
Ah looks like that param was added in v5
will try!
So that worked. On the
Pull Vercel Environment Information I for some reason get "Error: Project names can be up to 100 characters long and must be lowercase. They can include letters, digits, and the following characters: '.', '_', '-'. However, they cannot contain the sequence '---'."
But a Vercel issue at this point so will look into that. Thanks again!stormy-gold•17mo ago
No problem!
afraid-scarlet•13mo ago
"Unfortunately the Neon integration on Vercel doesn't allow you to pick a parent branch other than the default 🤔 I'll let the engineering team know"
Hi @Mahmoud I have this problem too, do you know if this got added to the roadmap, would help us a lot! thanks!
stormy-gold•13mo ago
do you mind sharing more details about your use case?
afraid-scarlet•13mo ago
We're using Clerk for our auth. Unfortunately preview support in clerk isnt great, so we have two separate clerk environments. Production and Staging. All our staging users exist in the
staging branch in neon. For preview environments we'd like Neon to branch off the staging db branch instead of the main branch.