Branch deploy settings for DEPLOY_PRIME_URL

Hello.

My site default subdomain is:

distracted-edison-fcd4c8.netlify.app

The primary domain is www.djctl.com. djctl.com is set to automatically redirect to www.djctl.com.

I have setup a CNAME to support a branch deploy of the staging branch:

staging.www.djctl.com is an alias for staging--distracted-edison-fcd4c8.netlify.app.

My branch deploy command is:

[context.branch-deploy]
  command = "npm run build -- -b $DEPLOY_PRIME_URL"

Is there a way to configure netlify such that when it goes to deploy the staging branch, it sets DEPLOY_PRIME_URL to staging.www.djctl.com rather than staging--distracted-edison-fcd4c8.netlify.app? It would be a way to define the primary domain mapping for the staging branch, much like we configure for the main branch.

Thank you for your help.

Hi @mhite,

$DEPLOY_PRIME_URL will always have the .netlify URL. But since you simply want to change the -b argument, why not use:

[context.branch-deploy]
  command = "npm run build -- -b https://staging.www.djctl.com"

Yes, I could hard code it. Was wondering if there is a more extensible way that could work with multiple branches potentially.

Just a follow-up. Ended up doing this:

[context.branch-deploy]
  command = "npm run build -- -b https://$BRANCH.www.djctl.com"
1 Like