Using Through github/ftp auto upload private repositoy to cpanel
GIthub Private repository with Cpanel Uploading step with one commit command from local pc repository to github and cpanel both
create git repository in github (https://docs.github.com/en/get-started/quickstart/create-a-repo)
after create an directory in local with github setup as following command
git init
git add .
git commit -m "commit"
git remote add origin
git push
step 1. create FTP account into cpanel
step 2. in Github Go to your private repository on GitHub, click on SETTINGS, then click on SECRETS to add your FTP account username, password and server IP
step 3. On the SECRETS tab, click the NEW REPOSITORY SECRET BUTTON on the right hand side, to add a new secret
step 4. Add the details as follows (Using your own details)
The names should be FTP_SERVER, FTP_USERNAME,FTP_PASSWORD
and the values should be your own secret details respectively and click the ADD SECRET BUTTON
The next step is to create a GitHub action workflow; The GitHub actions take place on the GitHub server.
In your GitHub repo, click on ACTIONS
Step 5. Click NEW WORKFLOW, You can choose a workflow template but for the sake of this tutorial, we will be creating our own workflow.
Click on any template (I selected the first template), then edit the configuration (“yaml” configuration file)
Step 6. Change the file name to your own choice. (I changed mine to deployCpanel.yml), make sure it has the .yml file extension
step 7. Place the below configuration code in the file
name: Publish Website to CPanel
on:
push:
branches:
- master
jobs:
FTP-Deploy-Action:
name: FTP-Deploy-Action
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/[email protected]
with:
ftp-server: ${{ secrets.FTP_SERVER }}
ftp-username: ${{ secrets.FTP_USERNAME }}
ftp-password: ${{ secrets.FTP_PASSWORD }}
Make sure you change the branch where you want your codes to be deployed from, in my case I am deploying from master branch
Step 8 . Once you are done, click on START COMMIT button on the right hand side
This will automatically create a /.github/workflows/directory and places the configuration file in it.
Anytime you push your codes to the master branch, it automatically deploys to cPanel via your FTP account.