Page tree
Skip to end of metadata
Go to start of metadata

Overview

In cPanel & WHM version 74 and later, cPanel's Git Version Control feature (cPanel >> Home >> Files >> Git Version Control) allows you to configure deployment for your cPanel-managed repositories. While many deployment configurations are possible, this document only outlines two types of deployment that you can configure.

Push deployment first pulls changes from a remote repository to your local computer. Then, you can push them to your cPanel-managed repository. The system will automatically deploy changes that you push to the cPanel-managed repository.

Push deployment.

Pull deployment pulls changes from a remote repository to your local computer and pushes new changes from your local computer to the remote repository. You can then use the Git Version Control interface ( cPanel >> Home >> Files >> Git Version Control ) to manually deploy changes that you pull from the remote repository.

Pull deployment.

Note:

You can use cPanel's Terminal interface ( cPanel >> Home >> Advanced >> Terminal ) to access the command line from within the cPanel interface.

Set up deployment

Note:

We recommend that you use this type of deployment.

Create an empty repository on your cPanel account.

If the repository that you wish to deploy does not already exist on your cPanel account, use cPanel's Git Version Control interface ( cPanel >> Home >> Files >> Git Version Control ) to create one.

Note:

For this type of deployment, do not clone a remote repository during this step. Instead, create an empty repository.



Clone the remote repository to your local computer.

If you have not already cloned it, use the terminal on your local computer to clone the remote repository.

For example, run the following command to clone a repository, where URL represents the remote repository's clone URL:

git clone URL


Create the .cpanel.yml file.

In order to deploy changes from a cPanel-managed repository, you must check a .cpanel.yml file in to the top-level directory of your repository. You can create and commit this file to your local computer's copy of the repository, or you can create and commit it on the remote repository.

  • If you use the remote repository, you will require read-write access or can submit a pull request to the remote repository.
  • This tutorial uses changes from the local computer rather than the remote repository.

For more information about the .cpanel.yml file, read our Guide to Git - Deployment documentation.

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

An example .cpanel.yml file.



Add the cPanel-managed repository as a remote.

From your local computer, run the following command to add the cPanel-managed repository as the local computer's remote:

git remote add origin URL

In this command, URL represents the cPanel-managed repository's clone URL.



Push changes to the cPanel-managed repository.

From your local computer, run the following command to push the changes from your local computer to the cPanel-managed repository:

git push -u origin HEAD

After the cPanel-managed repository contains the .cpanel.yml file, the system will automatically deploy any changes that you push to it.

Clone the remote repository to your cPanel account.

If the repository that you wish to deploy does not already exist on your cPanel account, use cPanel's Git Version Control interface ( cPanel >> Home >> Files >> Git Version Control ) to clone the desired remote repository.

Note:

This feature enforces several restrictions on clone URLs, and it verifies the remote host's public SSH keys for ssh:// clone URLs. For more information, read our Git Version Control documentation.




Clone the remote repository to your local computer.

If you have not already cloned it, use the terminal on your local computer to clone the remote repository.

For example, run the following command to clone a repository, where URL represents the remote repository's clone URL:

git clone URL


Create the .cpanel.yml file.

In order to deploy changes from a cPanel-managed repository, you must check a .cpanel.yml file in to the top-level directory of your repository. You can create and commit this file to your local computer's copy of the repository, or you can create and commit it on the remote repository.

  • If you use the remote repository, you will require read-write access or can submit a pull request to the remote repository.
  • This tutorial uses changes from the local computer rather than the remote repository.

For more information about the .cpanel.yml file, read our Guide to Git - Deployment documentation.

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

An example .cpanel.yml file.



Push changes to the remote repository.

From your local computer, run the following command to push the changes from your local computer to the remote repository:

git push origin HEAD


Pull and deploy changes from the cPanel interface.

To pull the changes from the remote repository and then manually deploy them, perform the following steps:

  1. Navigate to cPanel's Git Version Control interface ( cPanel >> Home >> Files >> Git Version Control ).
  2. Locate the desired repository in the list of repositories and click Manage.
  3. Click the Pull or Deploy tab.
  4. Click Update from Remote to pull changes from the remote repository.
  5. Click Deploy HEAD Commit to deploy your changes.

Repeat these steps each time that you wish to pull and deploy changes. The system will not deploy changes for this deployment type automatically.

Additional documentation