How to deploy any git repository to Netlify
Deploying a static web app takes 2 minutes.
If you don’t know Netlify, it’s one of this great recent outsider in the IaaS/PaaS industry (2015).
We’ve been using them recently to deploy our static web apps (Angular 5+). Performance, ease of use, advanced features like pre-rendering by default etc., makes it really convenient to use.
Not to mention they have a very, very interesting free tier. You can basically run any number of websites with unlimited bandwidth at top performance, period.
You can create a new site by connecting a repo to Netlify with the click of a button thanks to 3 integrations :
As we’re running our own custom GitLab instance, we needed a way to directly connect our repositories to Netlify.
Here’s how to :
- Install netlifyctl https://github.com/netlify/netlifyctl
brew tap netlify/netlifyctl
brew install netlifyctl
- Login
netlifyctl login
- Go to your repo directory
cd path/to/your/repo
- Checkout your master branch
- Run
netlifyctl init --manual
- Follow the instructions
- Make sure to correctly setup the “Publish directory”. It’s generally /dist
- The command line will output a public key, be sure to add it to your project settings on whatever Git hosting service you use. On GitLab you can do it on https://gitlab.(domain).com/profile/keys
- Configure the web hook the cli gives you, depending on what you need. Obviously “push” is required 😀
Test your configuration, you’re good to go 👍
You just have to push to master, and voilà!
If your git remote is named origin :
git push origin master
You’re left with basic configuration : domains, SSL etc. Netlify manages this fantastically, this is insanely simple.
Make sure to add the SSH Keys to your site : gitlab.com/profile/keys otherwise the web hooks won’t have the permission.
The profile obviously need correct permissions :)