When you’re working on a website, one of the things you need most is quick solutions to common questions.
There is little to no information on the internet about this topic, so I decided to create my own so that we all have the steps configured as best as possible for continuous deployment on Hostinger, via Git.
We need that every time we modify or change files on Github, they are automatically deployed or pushed to the live or production site.
You will need the following things:
- Connect your Hostinger web hosting account to your Git.
- Create a webhook on your Git
Done? Now let’s learn how to do these things easily and correctly.
We’ll assume you already have your repository on Github and your account on Hostinger is working as it should. If not, go to Github, create your repository, upload your files, and register with Hostinger to have everything you need to proceed.How to create a ropository on GitHub – How to open an account on Hostinger
How to connect Hostinger to Github.
Register with Hostinger – Hosting – Choose your domain – Advanced – GIT
After logging into your Hostinger account, go to Cpanel, scroll down to Advanced and then click on the Git icon.
In the next tab that pops up, you’ll see something like the image below:
This section will require your repository address, which will appear when you click on the Clone or Download dropdown menu if it is green:
Make sure you have uploaded all of your site files to your repository. While you can do this later, it’s better to have the most important files there at this step. (Images, CCS files, JS files, all need to be in this repository).
Don’t try to change the URL structure of your repository, leave it as it is unless you are sure what you are doing with the URL.
Now you need to go to your public_html folder, navigate to your file manager dashboard to do this:
Once you are in the file manager area, make a local copy of all the files there. (This is 100% recommended). Once all the files in the “public_html” folder are deleted, go back to the git page in your Cpanel.
In the Git configuration area of Hostinger, click the Manage button next to the repository you just created, then select Auto Deployment. This is the key to continuous deployment in Hostinger, via Git.
Connecting your GitHub repository.
Once you are in your repository dashboard, click Settings Webhook Add webhook, make sure you follow the steps as described.
In the webhook section, paste the URL you copied into Hostinger into the Payload URL section. For the content type, just choose application/JSON and you don’t need to change anything else.
If you change anything else there, be careful, avoid the risk! Now in reality drastically bad things will happen, probably your deployment will not work the way you wanted it to. After you have done all this, click the green button.
And there you have it!
Your Continuous Deployment on Hostinger, via Git, is set and ready to go.
Did I miss something, do you have a question? Share your comments below, and help others by sharing this post, maybe someone has the same doubts you had. Well, there are cases when things don’t work as expected, share your experiences in the comments below, I will be happy to help you.
If you need help on any step of the tutorial, don’t hesitate to contact us! We can do all this for you!
Thanks for caring in sharing!!!