πŸš€
Hosting

Git Deploy to Hosting: Automatic Deploys via GitHub or GitLab

28.12.2030
← All articles

Git deploy is the process where pushing code changes to GitHub or GitLab automatically lands them on your hosting. Instead of manually uploading files via FTP/SFTP β€” git push, done. This is the modern standard for web development.

Main approaches

cPanel Git Version Control β€” a feature built into cPanel. Connect a repository, choose a branch, and create a deploy. cPanel auto-pulls every branch change and deploys it. With a .cpanel.yml file you can run custom commands (composer install, npm build).

Webhook-based deploy β€” a push event in GitHub/GitLab calls a script on your server (via POST request). The script runs git pull and any other required work.

CI/CD pipeline β€” a more professional approach (covered in a separate article). GitHub Actions, GitLab CI, or Jenkins for test and deploy.

Setting up cPanel Git Version Control

1. cPanel β†’ Git Version Control β†’ "Create" button. 2. Clone URL β€” git@github.com:user/repo.git (SSH) or https://github.com/user/repo.git. 3. Repository Path β€” where to clone (e.g., /home/user/repo). 4. Repository Name. 5. After clicking Create the repository is cloned.

For deploys add .cpanel.yml at the repository root:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/user/public_html/
    - /bin/cp -R src/* $DEPLOYPATH
    - /bin/cp -R composer.json $DEPLOYPATH
    - cd $DEPLOYPATH && composer install --no-dev

Webhook deploy

For deploys via webhook: 1) On hosting create a PHP script: <?php exec('cd /home/user/repo && git pull && composer install'); ?>. 2) In GitHub repository Settings β†’ Webhooks β†’ Add β†’ Payload URL (yoursite.uz/deploy.php), Content type application/json, and protect with a secret token. 3) Select the push event. Now every push triggers an automatic deploy.

Security tips

Always use a webhook secret token and verify it in the PHP script. Deploy to production only from the main or master branch, never from a test branch. Always commit composer.lock and package-lock.json. Add .env and other secret files to .gitignore.

Sayt.uz practice

18% of Sayt.uz clients use Git deploy β€” mostly developers and custom Laravel or Node.js projects. cPanel Git Version Control is supported by default. Among our clients 47 sites use GitHub Actions for automatic deploys. Tip: for ordinary WordPress sites git deploy is unnecessarily complex β€” manual FTP is fine. For custom code (Laravel, Node, custom PHP) git is mandatory.

Related articles

πŸ’° Hosting Price Comparison: Uzbek and International Providers πŸ“‘ Server Monitoring Tools: Prometheus, Grafana, Datadog, and More 🌐 Edge Computing Hosting: Moving Compute Closer to Users 🏒 Colocation Server: Placing Your Own Hardware in a Data Center
🌐 Language
πŸ‡ΊπŸ‡Ώ O'zbek πŸ‡ΊπŸ‡Ώ ЎзбСк πŸ‡·πŸ‡Ί Русский πŸ‡¬πŸ‡§ English βœ“