Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub workflow for cpanel repository

I need help setting up a GitHub workflow so anytime I push to my GitHub repository the changes will be automatically pushed to my cpanel repository. I think this will be a better option than pushing to both GitHub and cpanel repository. This will also be helpful when multiple developers are working on the project and I would not have to share the password everytime.

like image 273
tolu olatubosun Avatar asked Jun 07 '26 22:06

tolu olatubosun


1 Answers

Deploying files to hosted websites through ftp

Your cpanel should accept ftp or sftp. So you can create a username/password with access to your cpanel directory and create a workflow like the below to push to it. The below user action will push to ftp on every commit.

Here are the docs on the github action that gets used below https://github.com/SamKirkland/FTP-Deploy-Action

 name: FTP Test
 on:
   push:
 jobs:
   ci:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
       - name: FTP-Deploy-Action
         uses: SamKirkland/[email protected]
         with:
           ftp-server: ${{ secrets.SFTP_SERVER }}
           ftp-username: ${{ secrets.FTP_USERNAME }}
           ftp-password: ${{ secrets.FTP_PASSWORD }}
           local-dir: toupload

Deploying to a git cpanel hosted repo

In this pipeline we are basically checking out the github code, and then changing the origin so that we can push code directly into CPANEL and commiting the code.

 name: Push To CPanel Git
 on:
   push:
 jobs:
   ci:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
       - name: Push to git repo
         run: |
             git remote set-url --add --push origin ssh://username@hostname/home/username/Project/example.git
             git add .
             git commit -m "Push to cPanel"
             git push https://${{ secrets.GITHUB_TOKEN }}@domain.com/username/example.git -f
like image 119
Edward Romero Avatar answered Jun 10 '26 04:06

Edward Romero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!