At times, you only want to focus on developing your code and push the changes automatically to your cPanel.
Well, this process can easily be accomplished using FTP and Github actions.
The process allows your code to be updated immediately you push your code to github.
In this guide, I’ll use a very simple static site.
Requirements
Access to cPanel
Github Account.
Basic understanding of CI/CD and Github actions.
Steps:
Step 1: Create an FTP Account on cPanel. #
- Log in to your cPanel account.
- Navigate to the
Files
section and click onFTP Accounts
. - Click on
Add FTP Account
. - Enter a
username
andpassword
for the FTP account. - Choose the directory that the FTP account will have access to. For example:
public_html
- Click on
Create FTP Account
.

Step 2: Setup FTP credentials into the GitHub repository #
To set FTP credentials into a GitHub repository secret, follow these steps:
- Go to your GitHub repository and click on
Settings
. - Click on
Secrets and variables
on left sidebar undersecurity
section - Click on
Actions
. - Click on
New repository secret
. - Enter a name for the secret, such as
FTP_USER
. In the Value field, enter your FTP credentials. - Click on
Add secret
to save the secret.
Settings

Secrets and Variables

Repo secrets
If you have exixting repo secrets, you can also edit as needed.

Step 3: Add your Deployment Script. #
In this setup, I have a simple static site.
Now add a deploy.yml
file to your files. You should have a structure similar to one below.
.
├── .github
│ └── workflows
│ └── deploy.yml
├── index.html
├── LICENSE
└── README.md

In this file tree, The deploy.yml
file in the workflows
directory the configuration file for a GitHub Actions workflow that will deploy the project to your cPanel server.
The index.html file is my the main HTML file for the project. Now update the deploy.yml
file using the following code snippet: You can adjust as needed to suit your needs.
on:
push:
branches:
- main
name: Deploy Website to cPanel on Push
jobs:
web-deploy:
name: Deploy Website
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v4
# Sync files via FTP
- name: Sync Files via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
exclude: .git,README.md
Step 4: Push your code to github #
Push your code to github and let the job run.
git add .
git commit -m "Your commit message here"
git push origin main
This will push your local main branch to the remote repository and update the main branch on the remote repository with your changes. After a few seconds, you will see the website has updated automatically. From now on each time you push on the main branch, it will update the website automatically.
To View the actions, Go to Github -> Actions
You should see something similar to one below. Ensure you’re on the repository for which you are working on.

Now reload your site and see your changes.
That’s all. You’ve successfully connected your application to Github and cPanel and can now push changes automatically.