CPANEL AUTO DEPLOYMENT WITH GITLAB

 CPANEL AUTO DEPLOYMENT WITH GITLAB

Step 1 : login  in Your git lab account and create a  .gitlab-ci.yml file  in that project which u want to auto deploy to the cpanel

Step 2 :  Edit .gitlab-ci.yml file and add this code

deploy:
  script:
    - apt-get update -qq && apt-get install -y -qq lftp
    - lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnv ./ ./public_html/--ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
  only:
    - master

Step 3 : Now you have to set Environment variables    for $username, $password and $host value for that

Go to Gitlab Project settings >>  CI/CD >> Environment variables

Environment varabiles
 
Step 4  : now every merge of your master branch will run gitlab pipeline and run this script

 

Important note * :-  $host is your ftp host it will be like ftp.<yoursitename>.com $password is your cpanel password and $username is Your cpanel password

hoainguyen