Git manual/pull deployment: a little help to understand the approach

AislinnMc

Registered
Aug 6, 2020
1
0
1
Belgium
cPanel Access Level
Website Owner
Hi,

I'm implementing manual git deployment (see Guide to Git™ - Deployment | cPanel & WHM Documentation) and it's not working as expected.
I'd love some help to understand how to this!

What I've done is:

1) Create staging.mydomain.com which points to /home/my_username/_staging.mydomain.com. This folder is empty.

2) Connect an existing repo using Git™ Version Control.
This is saved under /home/my_username/git_repos/staging.mydomain.com and contains all the files pulled from github, including this .cpanel.yml file:

Bash:
---
deployment:
  tasks:
    - export DEPLOYPATH=/home/my_username/_staging.mydomain.com/
    - export SRCPATH=/home/my_username/git_repos/staging.mydomain.com/
    - /bin/rm -rf $DEPLOYPATH/*
    - /bin/rsync -av --exclude='.git/' --exlude='.gitignore*' --exlude='.cpanel.yml*' $SRCPATH $DEPLOYPATH
3) Go to Git™ Version Control > Manage > Pull or Deploy > Update from remote (this works) then Deploy HEAD Commit (this doesn't seem to do anything).

What I'm trying to accomplish, based on my understanding of this process, is to store my repo in one place, manually update it when I push new changes then deploy it using .cpanel.yml which should copy all the relevant* files from the repo into the subdomain's folder.

This last step (copy-paste) is not working: my subdomain's folder remains sadly empty.

What am I missing?

* Since the documentation says "Don’t use a wildcard character, such as an asterisk, to deploy all files. This could deploy items like the .git directory and cause serious problems."
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,263
313
Houston
I think this documentation may be more along the lines of what you need: Guide to Git™ - How to Set Up Deployment | cPanel & WHM Documentation

I also believe that the .cpanel.yaml file should be configured to only export the DEPLOYPATH not the SRCPATH and you've got the DEPLOYPATH declared incorrectly if you're attempting to take the Sites Files in /home/public_html/staging.mydomain.com/ and place them in /home/public_html/_staging.mydomain.com/

Something like the examples in Guide to Git™ - Deployment | cPanel & WHM Documentation

The deployment YAML file
The .cpanel.yml file determines how and where the changed files deploy. You must check a .cpanel.yml file in to the top-level directory for each cPanel-managed repository that you deploy. The .cpanel.yml files must use the format in the examples below.

Important:
  • The files below are only examples. You must update them to suit your needs. These files will not allow you to deploy a repository successfully.
  • Don’t use a wildcard character, such as an asterisk, to deploy all files. This could deploy items like the .git directory and cause serious problems.
  • Don’t use characters that are invalid in YAML files. For more information, read the Escaped Characters section of yaml.org’s YAML Specification.
***Note that not only are you unable to use wildcard characters but you cannot use Escaped Characters in a .yaml file. This would include "_"



Requirements
Before deployment, repositories must meet the following requirements:

  • A valid checked-in .cpanel.yml file in the top-level directory.
  • One or more local or remote branches.
  • A clean working tree.
***Note that they require the .cpanel.yml being present in the top-level directory


Deploy an entire directory
The following .cpanel.yml file deploys all files in the images directory to that directory in the example account’s public_html directory:
*** Note that they're deploying to the public_html from the images directory