Connect your Github private Repository to cPanel and Deploy your website

Connect your Github private Repository to cPanel and Deploy your website




deploying-project-from-local-pc

  1. First, go to your cPanel and in the Search bar search Terminal.
  2. Open the Terminal
  3. Type: ssh-keygen -t rsa -b 4096 -C "username@example" 
  4. Username defines your cPanel username and example defines your domain name.
  5. Hit Enter
  6. It crates your Private and Public keys
  7. To ensure that Type:cat ~/.ssh/id_rsa.pub
  8. If you succeed to generate then it shows you public key.
  9. Now Type:cat ~/.ssh/id_rsa
  10. It gives your Private key.
  11. Copy both your Public and Private keys to a text file for use in the future.
  12. Done for the server now time to configure GitHub repository.
  13. Create a new repository or use an existing repo to deploy in the cPanel. It would be better to make your repo is private.
  14. Click the repo and go to the settings tab.
  15. Now Click the add deploy key. 
  16. Insert a name[key_name][it’s your choice] in the name input field.and also insert your public key in the key field and save it.
  17. Done in the Github.
  18. Now add some files in the Github repo.
  19. Now times to deploy your GitHub files in your cPanel.
  20. Go to your cPanel.
  21. Click Git™ Version Control
  22. Ensure that you have enabled your shall access.if not then contact your hosting provider.
  23. Click in the Create Button.
  24. Make sure Clone a Repository toggle is on.
  25. And now go to your GitHub repo and copy the SSH clone path. (Clone with SSH must be enabled/generally, it has https enabled)
  26. Copied URL paste in the cPanel Clone Url input field and give a location and also give a repo name.
  27. It creates a repo .and back to your repo section.
  28. Select your repo and click manage Button.
  29. Then click Pull or Deploy tab
  30. It gives all info about repo and also give the buttons to update your repo from GitHub(update from remote).
  31. Now go to your local computer directory and make .cpanel.yml file.
  32. And include the following codes:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/user/public_html/
    - /bin/cp index.html $DEPLOYPATH
    - /bin/cp style.css $DEPLOYPATH

  1. The user defines your cPanel username
  2. Save all files
  3. Commit and push now in the GitHub.
  4. Check whether it committed or not.
  5. Then if committed successfully then go to your cPanel.
  6. Click your Git™ Version Control
  7. Click your repo and click manage Button.
  8. Then go the  Pull or Deploy tab
  9. Now click the update from remote Button
  10. After updating full repo from Github then click Deploy HEAD commit
  11. Check ur Public_html folder if successfully deployed then it shows your files.
  12. Now visit your website and see what happens.

You may like these posts