In cPanel & WHM versions 74 and later, cPanel's Git Version Control ( cPanel >> Beranda >> File >> Kontrol Versi Git
) feature allows you to configure deployments for cPanel-managed repositories. While many deployment configurations are possible, this document only outlines two types of deployments you can configure.
You can use the cPanel Terminal interface (
cPanel >> Home >> Advanced >> Terminal
) to access the command line from within the cPanel interface.
Push deployment
First pull the changes from the remote repository to your local computer. Then, you can push them to the cPanel managed repository. The system will automatically apply the changes you pushed to the cPanel managed repository.
Push deployment
1. Create an empty repository in your cPanel account.
If the repository you want to deploy doesn't already exist in your cPanel account, use cPanel's Git Version Control interface ( cPanel >> Beranda >> File >> Kontrol Versi Git
) to create one.
2. Clone the remote repository to your local computer.
If you haven't cloned it yet, use the terminal on your local computer to clone the remote repository.
For example, run the following command to clone a repository, URLwhich represents the remote repository clone URL:
git clone URL
3. Create a .cpanel.yml file.
To apply changes from the cPanel-managed repository, you must check for the .cpanel.yml file in 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 to a remote repository.
- If you are using a remote repository, you will need read-write access or be able to submit pull requests to the remote repository.
- This tutorial uses changes from the local computer rather than a remote repository.
For more information about the .cpanel.yml file, read the Guide to Git - Deployment documentation.
Example:
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- /bin/cp index.html $DEPLOYPATH
- /bin/cp style.css $DEPLOYPATH
4. Add the cPanel managed repository as a remote.
From your local computer, run the following command to add the cPanel-managed repository as a local computer remote:
git remote add origin URL
In this command, URL represents the URL of the cPanel-managed repository clone.
5. Push the 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
Once the cPanel-managed repository contains the .cpanel.yml file, the system will automatically apply any changes you push to it.
Pull deployment
Pull changes from the remote repository to your local computer and push new changes from your local computer to the remote repository. You can then use the Git Version Control ( cPanel >> Home >> Files >> Git Version Control
) interface to manually apply the changes you pulled from the remote repository.
Pull deployment
1. Clone the remote repository to your cPanel account.
If the repository you want to deploy to does not already exist in your cPanel account, use the cPanel Git Version Control interface ( cPanel >> Beranda >> File >> Kontrol Versi Git
) to clone the desired remote repository.
This feature enforces some restrictions on the clone URL, and verifies the remote host's public SSH key for the ssh://clone URL. For more information, read our Git Version Control documentation.
2. Clone the remote repository to your local computer.
If you haven't cloned it yet, use the terminal on your local computer to clone the remote repository.
For example, run the following command to clone a repository, URLwhich represents the remote repository clone URL:
git clone URL
3. Create a .cpanel.yml file.
To apply changes from the cPanel-managed repository, you must check for the .cpanel.yml file in 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 to a remote repository.
- If you are using a remote repository, you will need read-write access or be able to submit pull requests to the remote repository.
- This tutorial uses changes from the local computer rather than a remote repository.
For more information about the .cpanel.yml file, read the Guide to Git - Deployment documentation.
Example:
---
deployment:
tasks:
- export DEPLOYPATH=/home/user/public_html/
- /bin/cp index.html $DEPLOYPATH
- /bin/cp style.css $DEPLOYPATH
4. Push changes to the remote repository.
From your local computer, run the following command to push changes from your local computer to the remote repository:
git push origin HEAD
5. Pull and deploy changes from the cPanel interface.
To pull changes from a remote repository and then apply them manually, perform the following steps:
- Navigate to the cPanel Git Version Control interface (
cPanel >> Beranda >> File >> Kontrol Versi Git
). - Find the desired repository in the list of repositories and click Manage .
- Click the Withdraw or Deploy tab.
- Click Update Remotely to pull changes from the remote repository.
- Click Deploy HEAD Commit to apply your changes.
Repeat this step every time you want to pull and apply changes. The system will not apply changes for this type of deployment automatically.