Hi friends, In this article, I am going to write about how to deploy public github repo to server. Only we will discuss about public git repository.
Although it’s most typically used in the software development process for deploy the code in server. Git is a version management system that can be used to track changes in any file and git deployment to any server.
It help to deploy code in production very fast after pushing. Here i will use github actions deploy to server ssh automatic.
Introduction
Microsoft is parent company of Github. Chris Wanstrath, P. J. Hyett and Tom Preston Werner are founder of Github. It is founded in February 8, 2008 and Launched in April 10, 2008. Thomas Dohmke, Mike Taylor and Erica Brescia are respectively CEO, CFO and COO at Github.
Github Deployment
First, You have to login your hosting provider. In case, I have hostinger which is low budget and best performance with unlimitted bandwith, multi subdomain access free and also free SSL for website. So, I do the deployment steps with hostinger.
Now, You have to switch Git dashboard in hostinger. Go to the Advance section and tap the Git option in Hostinger.
There are several steps to complete your github deployment.
1. Add SSH Key in Github
If you are a new user, you see the generate SSH key option instead of the remove SSH key option in the Private Git Repository section. Just tap it. After appear SSH key front of you. Copy this SSH key and go to your GitHub public repository in your GitHub account.
- Tap on the Setting tab at the top right menu and scroll down the page.
- Tap on the Deploy keys section on the left sidebar.
- Tap add deploy key.
- Enter your key name in Title section.
- Paste SSH key in the Key section.
- Tap add key.
Congratulation, You have been added an SSH key successfully.
2. Copy the GitHub public repository URL
Come back to your Hostinger Git dashoard in Hostinger.
3. Add Github Repository in Hosting
- Paste public git repo url in the Repository section.
- Add branch name in the branch section. By default, it is the master branch.
- If you leave empty the directory section, Then the public repository is deployed in /public_html/, which is the root directory.
NOTE:- In my case, I don’t want anyone to override my website. So I put the test folder’s name in the directory section. Now deployment will be in the test folder.
- Tap the Create button.
- Tap Deploy button.
Congratulation, You have been added your public github repository for deploy from github to server.
NOTE:- If you change your GitHub public code in your system or from anywhere. Then you have to come to your hosting provider to upload to server and tap on deploy button again and again. If you want git auto deploy after push. Checkout next point.
Auto Deploy to server after push
- Tap Auto Deployment Button.
- Copy webhook URL.
- Click Setup Webhook on Github link.
After clicking the link, you will be redirected to github.
- Paste copied URL in the Payload URL section.
- Tap add webhook button.
Congratulation, You have been automated deploy github to server.
When you will commit and push. Automatic changes may occur in deploy website on github.
Thanks for reading this article 🙂