---
title: How to push changes to your code on cpanel using github actions and FTP.
description: 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…
url: "https://truehost.com/support/knowledge-base/how-to-push-changes-to-your-code-on-cpanel-using-github-actions-and-ftp/"
updated: "2024-12-13"
category: Cpanel
---

# How to push changes to your code on cpanel using github actions and FTP.

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 on **`FTP Accounts`.**
- Click on **`Add FTP Account`.**
- Enter a `username` and `password` for the FTP account.
- Choose the directory that the FTP account will have access to. For example: `public_html`
- Click on **`Create FTP Account`.**

![](https://truehost.com/support/wp-content/uploads/2024/12/image-172-1024x249.png)

### **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 under **`security`** 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

![](https://truehost.com/support/wp-content/uploads/2024/12/image-173-1024x130.png)

Secrets and Variables

![](https://truehost.com/support/wp-content/uploads/2024/12/image-175.png)

Repo secrets

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

![](https://truehost.com/support/wp-content/uploads/2024/12/image-176.png)

### **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`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-178.png)

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/FTP-Deploy-Action@v4.3.4
          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.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-180-1024x455.png)

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.
