> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.sparkedhost.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to Automatically Deploy from GitHub to cPanel

Elevate your web development game by automating GitHub to cPanel deployments. With [Sam Kirkland's FTP Deploy GitHub Action](https://github.com/SamKirkland/FTP-Deploy-Action), you can have a smooth transition from coding to production, allowing you to focus on your code, not deployment hassles.

|| Please note that this method will require you to have a FTP Account to the `public_html` or subdomain folder already made for the Automatic Deployment. You can follow [our FTP Account on cPanel Article](https://help.sparkedhost.com/en/article/how-to-add-a-ftp-account-on-cpanel-16zy80o/) on how you can create one.

### How to Automatically Deploy from GitHub to cPanel

1. On your GitHub Repository, go to the Repository's Settings and then go to the Actions' Secrets and Variables

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/image2023-12-21174354813_132n6tw.png)

2. Create 3 New Repository Secrets:
| Secret Name| Secret Value|
| --- | --- | 
| FTP_SERVER | Set this to the domain to your website, for this article we will be setting it up for the `sparkedhost.rob0520.xyz` domain | 
| FTP_USERNAME | Set this to the Username of the FTP Account|
| FTP_PASSWORD | Set this to the Password of the FTP Account|

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/image_1ricqg9.png)

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/image_2awa30.png)

3. Go to the Repository's Actions and click on the `set up a workflow yourself` hyperlink. If you have previously made a different GitHub Action, click on the "New Workflow" button and you should be able to see the hyperlink.

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/image_16fvvy2.png)

4. Copy the following code and paste it to the Action file contents, then Commit Changes.

```
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: ${{ secrets.FTP_SERVER }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
```

Optionally, if you want to exclude certain folders or files from the Automatic Deployment, let's say a folder named `logs` and a file named `notes.txt` for example. You can paste the following lines at the end of the Action:

```
exclude: |
    **/.git*
    **/.git*/**
    **/logs/**
    notes.txt
```

| If you do require to exclude certain folders or files, make sure to also list down `**/.git*` and `**/.git*/**` like the above, as having the `exclude` key overwrites the default values.

So it will look something like this:

```
on: push
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: ${{ secrets.FTP_SERVER }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
        exclude: |
            **/.git*
            **/.git*/**
            **/logs/**
            notes.txt
```

Now, every time you commit changes on the Repository. It will automatically deploy the changes to your website!

---

If you require any further assistance, please create a ticket [here](https://billing.sparkedhost.com/submitticket.php).

---

Created By: Alecz R.