DEPLOY_PRIME_URL: URL representing the primary URL for an individual deploy, or a group of them, like branch deploys and Deploy Previews; for example, https://feature-branch--petsof.netlify.app or https://deploy-preview-1--petsof.netlify.app.
You would most likely have to rely on Git commands to get a branch name. Not sure if it’s the right one in context of a PR, but maybe git status --branch shows the correct one?
I don’t know more than Gualter But I think you should be able to use the git command line utility to get that information, though I do not know how exactly. But, once we start your build, we do have a full clone of the repo, so commands accessing the local copy of the clone - like git status - just work normally. Perhaps you can find a way to use those to show the info you need? We’re not super-experts on command line git, so you may have to do the research yourself to find the details
Using the HEAD env var is working for me (any variation of git status does not, as Netlify creates a new temporary branch with the build ID as the name).
I need to know the HEAD branch name as it was created in GitHub, so I can properly pass it along to a build plugin to define which build command should be used. The end goal is to tell Netlify when to build a deploy preview using develop, staging or production vars
Using process.env.BRANCH outputs something like pull/:pr-id/head.
It would be nice to have a way to get this info directly from Netlify.