How CI/CD on Shared hosting using cPanel Git Version With 3 Way Simple

Soefyan Syah
Soefyan Syah20 Oct 2022
CICDGithubLaravelcPanel

This got me thinking and asking about whether there are alternatives to this, and there certainly are and it is the result of Git, GitHub and cPanel that I will detail in the following sections;

How CI/CD on Shared hosting using cPanel Git Version With 3 Way Simple
Photo by Yancy Min on Unsplash

In recent years I have studied the Continuous Integration and Continuous Deployment (CICD) methodology and tried to apply it.

For hobby projects, I usually use netlify.com or vercel.com and github.com and take advantage of the CICD convenience features they provide with just a click and it's cool with 0$, although it has some limitations.

It occurred to me, whether CICD can be done between cPanel and github. then i try to type some keywords on google like

cicd cpanel github,

cPanel Git auto deploy,

CI/CD Github Laravel,

Laravel GitHub Actions,

How to Create CI/CD with Github Action and Laravel

from the results of searching for tutorials on google, I finally adjusted it to my needs and case.

in this case I use

Laravel 9,

PHP 8.1,

Private repo

Why use cPanel for CICD because the price is relatively more affordable when compared to AWS, I admit there is no hobby project that can handle the expensive overhead that AWS brings.

The whole process can be divided into 3 simple Phases:

Create a private repository on your GitHub account,

Create a cPanel FTP account from your cPanel dashboard,

Create a YAML file (in your git repository '.github/workflows' folder),

Create a repository in your GitHub account,

I'm sure you can make this easily.

Create a cPanel FTP account from your cPanel dashboard,

I believe you can easily ftp account in cPanel after creating ftp account in cpanel create secret action in your private github repository.

and create secret action like below,

Create a YAML file (in the right folder of your git repository)

Use your favorite edit, in this case I'm using vscode. create a folder ".github/workflows" then create a file with the extension *.yml or adjust the file name you want for example 'cpanellaravel.yml' then copy the code below

name: cpanellaravel
on: push
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v2
    - name: Upload ftp
      uses : SamKirkland/FTP-Deploy-Action@4.3.2
      with:
        server: ${{ secrets.ftp_server }}
        username: ${{ secrets.ftp_username }}
        password: ${{ secrets.ftp_password }}
    - name: running command ssh
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST_SSH }}
        username: ${{ secrets.USERNAME_SSH }}
        password: ${{ secrets.PASSWORD_SSH }}
        port: ${{ secrets.PORT_SSH }}
        script: |
          cd panelpdd/
          composer install

yml script above with flow if there is a push in the repository then yml will send only the files that have been changed. then the next script will do a composer install .

Soefyan Syah

Written by Soefyan Syah

Hey there! I hope you find this post useful. If you have anything to say, questions or feedback, send me a tweet or an email.