How do you set dynamic environment variables for a pages deployment

We need to set dynamic environment variables for preview deployments, namely, their git branch, commit, and GitHub PR number. We want to use this information in turn to connect preview deployments to their own isolated database.

1 Like

We provide some by default, not PR number but branch and commit are there already:

Thanks @WalshyMVP that is indeed helpful.

Still I can’t imagine hardcoded being able to cater to every use-case. Already missing PR number is a pain since branch names are potentially long identifiers and not suitable for deriving other things like a database name since it might require truncation (or removing special characters) which immediately opens one up to database name collisions etc.

And I imagine there are nth other examples where the built in stuff won’t cut it.

So, what are the plans for extensibility here if any?

Thanks!

Are you wanting these within builds or within Functions?

For Functions, I’ve been thinking about this and have some stuff written up for it.

For builds, I’m not sure how that would work. You’re able to just set them yourself since it’s just a regular Linux container.

For us, functions, because we’re looking to make a dynamic connection string at runtime to connect to preview database isolated for just that deployment.

Perfect

Yeah no timeline on this right now sadly. It is something I want to build though.