Deploying "private" code

Hello :wave:t2:

This may not be an issue with Netlify itself but I’m wondering if anyone has found a solution for this particular use case.

I’m want to use the deploy button (e.g. https://app.netlify.com/start/deploy?repository=https://github.com/netlify/netlify-statuskit) to set up a sites for customers but don’t necessarily want to have to have the repository public on Github.

I’ve thought about issuing customers with a ZIP file to upload to Netlify but after uploading it doesn’t take the user through the same nice deployment path that the deployment button does. Because the way it sets up build tasks and environment variables through the TOML file is really, really nice.

Can this be done via Gitlab? I’ve had a look through the docs but maybe I’m just missing something.

Any help would be amazing. It seems like it’d be a good problem to solve because there’s so many customers that could be sent Netlify’s way using this method without giving the source code out publically.

Cheers.

Hiya @benjaminreid and welcome to our community!

Unfortunately due to the way that the button works, folks need to be able to fork your repo without any git permissions, so it is not intended to work on private repos.

As you notice, the zip option doesn’t guide them through setting any settings.

So is there a middle ground? fortunately yes! You could provide a netlify.toml that has all the variables needed listed using placeholder values, and your build command could have some smarts that guide folks into changing those before a deploy could succeed, and sends a useful message while failing if they are default.

Something like this (untested!) may work:

[build]
  command = sh ./script.sh
[build.environment]
  API_ENDPOINT="unconfigured-update-netlify-toml"
#!/bin/sh

# variable API_ENDPOINT needs to be set to a non-default value for this check to pass
if [ "$API_ENDPOINT" == "unconfigured-update-netlify-toml" ] ; then
  echo "you need to commit changes to netlify.toml to set variables as mentioned in the README"
  exit 1
fi
npm run build # or your normal build command

This will block folks from deploying without changing, and gives them as much detail as you want to provide about how to configure. Not quite as magical as the button … but maybe functional enough?

Thank you very much, I really appreciate the reply. This does sound like a good middle ground, I’ll see what I can do with it :sweat_smile:

Hey! I’m in the same boat, except I’d really like to hook into the stack=cms option of that URL that sets up the identity and git-gateway for Netlify CMS. Right now the only option I’ve come up with is an express server that serves up a git repo with a unique auth token for the user in the url. https://app.netlify.com/start/deploy?repository=https://mydomain.com/git/authtoken/gatsby-project&stack=cms It would be AMAZING if we could get these identity and git-gateway setup options available either through the Netlify API (where I could set it up automatically for my customer) or through the TOML file!

Hi @rosswaycaster, you can set up Identity and git-gateway using Netlify API.
We have some code that does it in the Netlify CMS repo for testing purposes (even enables Large Media and create an identity user).
See https://github.com/netlify/netlify-cms/blob/0ac3592e2617ef2c3b108d4256cd977787dcf4b2/cypress/plugins/gitGateway.js#L210
Please let me know if that can work for you.