Env var expansion in env vars?

Hello,

I’m using the new environment variables settings to set different values for each deploy context. On deploy previews, I would like to make the value dynamic by using the Git metadata REVIEW_ID. For example:

Env var Context bar
API_URL Production https://domain.com/api
API_URL Deploy Previews https://$REVIEW_ID.domain.com/api

I’ve tried using both $REVIEW_ID and ${REVIEW_ID} in the value but neither appears to work. Is it possible to do this?

Thanks

Hi Alistair,

Indeed that is not possible.

If both variables are available, of course you can achieve equivalent results by interpolating twice:

#!/bin/sh
DOMAIN=domain.com
PATH=/api
METHOD="https://"
INTERPOLATED_SUBDOMAIN=$REVIEW_ID
INTERPOLATED_URL=${METHOD}{$INTERPOLATED_SUBDOMAIN}.{$DOMAIN}{$PATH}
npm run build -d MYVAR=$INTERPOLATED_URL