I’m designing a (slightly convoluted) build process where I checkout multiple branches of the same repository during the build. I’m unable to get this working in Netlify’s build environment and wanted to verify that there’s no other way to do it before I give up:
I tried git checkout origin/$secondBranch but the git repository is checked out in a detached head and has no other branches fetched locally.
I tried git remote add origin $REPOSITORY_URL && git fetch origin but it seems the build environment isn’t set up with SSH access to the same repository.
Most of the docs online suggest using the https address of the repository but I cannot as it’s a private repo, and I’m not interested in giving Netlify a build token at the moment.
Hi there and sorry it’s been awhile since you posted! I do not think this is going to work without SOME kind of authentication you provide during build process. See this article for more details:
I know you don’t want to use a token specifically, so you could also do something even more convoluted like this:
…but it still boils down to “you have to get authentication details into the build shell somehow”.
Everything else I can think of is even yet still more convoluted - can you make a submodule out of a different branch of this repo? If so you could use a deploy key in the intended way but my gosh that seems to be begging for a recursive explosion during checkout if it is even possible to configure.
So instead I’ll add your voice to a feature request to be able to customize a bit how we check things out. Could you clarify for me what you think would work better for your purposes? I know the “detached head without branches” isn’t working for you - do you happen to know what kind of checkout might work better? e.g. git clone --depth X or some other specification like that would be very helpful!