I have seen many ways to deploy a GitHub repository to shared hosting (cPanel).
But there are so many ways, and they are not all the same, and the solutions are not especially clear to me.
Firstly, I want to know how to set it up so that the shared hosting will change automatically when we update a repository to be deployed.
Secondly, is it possible to manage it both manually and automatically for making changes (I prefer automatically, but I also want to know how to do it manually).
I think I understand what you are looking for. A good way of deploying your GitHub repository to CPanel is through GitHub Actions and an FTP connection.
Create a new action in your GitHub repository, which will prompt the creation of a main.yaml
file which you can fill with the following code taken from https://github.com/marketplace/actions/ftp-deploy.
on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v2
- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@4.3.0
with:
server: ftp.samkirkland.com
username: myFtpUserName
password: ${{ secrets.ftp_password }}
Customize your server, username and password (preferably using repository secret variables) and every time there is a commit to the main branch, the files will be uploaded/modified in the FTP repository.
Here is a walkthrough in case you need more help: https://youtu.be/UNWIXYSZfZY