Hosting Prestashop, Magento y WordPress listo para usar, optimizado y con mejoras exclusivas. Soporte especializado, servidores en España
Chat
¿Hablamos?
There was a problem loading the comments.

Manage GIT from cPanel

Support Portal  »  Knowledge base  »  Viewing Article

  Print

Managing GIT from cPanel

Although pulling files to our repository in cPanel is automatic and does not require any additional action on our part, to manage deploys in cPanel we will have to create a .cpanel.yml file, where we will tell you where the files have to be copied to when we click on"Deploy".

To manage GIT from cPanel, we will access to the menu option "Git Version Control". We can type "git" in the top search bar so that it appears as the first result.
When accessing, we will see our cloned or created repository and we will be able to manage it by clicking on"Manage", highlighted with a blue box below:

4dc86d275bcb134325abba9000a900eb6b4bcb49?t=af06bb709274131cfa16b10c9fc0820b

If you do not yet have a repository created or cloned, you may be interested in the following articles:

Create .cpanel.yml file

To create the .cpanel.yml file we will have to create it first in our original repository, we will not be able to create it from cPanel, as it will not detect the file if there are pending changes in the current branch. As we want to create a file, it will already detect it as a change and therefore will not detect it as valid, therefore, we must create the file either from our local cloned repository or directly from GitHub, Bitbucket, or whatever you are using.

In our case, we are going to create it directly on GitHub.Our repository contains a src/ directory with all the code we need, so our .cpanel.yml looks like this:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/testsfd/public_html/
    - /bin/rm -Rf $DEPLOYPATH
    - /bin/mkdir $DEPLOYPATH
    - /bin/cp -R src/. $DEPLOYPATH

You will have to modify the paths according to yours. You can check them in the cPanel File Manager if you are not sure.
In this file what we do is to define the path where we want our code to be copied, previously we delete that same directory, we create it and finally it is copied. This way, we make sure that if there is any file that has been deleted, it disappears when copying.

This file .cpanel.yml we will have to upload it to our GIT and it will have to be in the upper directory, in our case, it would look like this:

a3351daac7e9c1cb31e08b3be75bb8863eb5f425?t=21c1b3ec5e27e4e30c068bf9e1c26b49
Once the file is saved and uploaded to GIT, we will proceed to synchronize it from cPanel using the"Update from Remote" button, highlighted in a blue box:

ba14d634001a51fbf0e7055d0724693b7cacf798?t=850dfab0f41669806877ded9f0d80b30
If everything is correct, we will see the message highlighted with an orange box, which tells us that it is detecting the .cpanel.yml file and we will be able to perform a deploy.

Perform a deploy

To move our changes obtained in the repository, first we will have to fulfill certain requirements:

  1. A .cpanel.yml file created in our home directory.
  2. One or more remote or local branches.
  3. A clean working tree, that is to say, that there are no files pending commit, conflicts or similar.
We understand that these requirements are being met, since we will not be working directly with our files on the server, but we will be getting them from GIT, where they will have been previously uploaded from a local or test environment.

Therefore, there are two ways to deploy:
  • Manual: If you have the main GIT repository outside cPanel, this will be the usual procedure.
  • Automatic: If your main GIT repository is the repository of your cPanel account, any push you make will automatically execute the .cpanel.yml file, deploying to the main directory without the need for you to do anything else.

Perform a manual deploy

Therefore, to deploy a specific branch, we must first make sure that we are in the desired branch, normally, it will be master. We select it in Checked-Out Branch and click on Update:

363fa879f316263765882b7e48229acdf9614856?t=e2804e7ec6a31de91fe57ab02c3bd0ea
After this, click on the Pull or Deploy tab and inside, on Deploy HEAD Commit, highlighted in a blue box below:

69ea38dd1a3ecae4ec71cbfa1b0b2a36a2ddb415?t=c4df139bef2cc9575d190a3c4ad5bd41
Depending on the number of files, it may take more or less time. After finishing, we will see the message highlighted in an orange box, where it will show us the last commit we have deployed.

If you have any doubts, you can always contact us or consult the cPanel documentation: https://docs.cpanel.net/knowledge-base/web-services/guide-to-git-deployment/

Si todavía tienes dudas, contacta con nosotros y te ayudamos.


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© FactoriaDigital.com