Deploy Your Site to InfinityFree or Any cPanel Hosting Using GitHub Actions and FTP

Dan OngudiDan Ongudi
4 min read

This guide will walk you through the steps to automate your deployment process from GitHub to a cPanel-based hosting environment, such as InfinityFree, using GitHub Actions and FTP.

Prerequisites

  • A GitHub repository containing your website or blog's source code.

  • A cPanel-based hosting account (like InfinityFree) with FTP access.

  • FTP credentials (server, username, password).

  • Access to GitHub Actions (built into all GitHub repos).


Step 1: Create an FTP User in cPanel

If you're using a hosting provider with cPanel:

1. Log into your cPanel

2. Add an FTP Account

  • Under Files, click FTP Accounts.

  • Fill out the form under Add FTP Account:

    • Login: e.g., deployuser

    • Password: Strong password (you'll need this later)

    • Directory: e.g., public_html/ or a subfolder

    • Quota: Set to "Unlimited" or specify a limit

  • Click Create FTP Account.

3. Save the Credentials

  • Note down your FTP Username and Password.

  • You may also see the FTP Server (often something like ftp.yourdomain.com).


Step 2: Get FTP Credentials from InfinityFree

If you're using InfinityFree:

1. Log into InfinityFree

2. Get FTP Details

  • Under My Accounts, select your domain and click Manage.

  • Scroll down to FTP Details and copy:

These details will be used in the GitHub Action later.


Step 3: Create a GitHub Action Workflow

Inside your repository:

1. Create the Workflow File

Create .github/workflows/deploy.yml and paste the following:

name: 🚀 Deploy to your_domain

on:
  workflow_dispatch: # Uncomment below to deploy on push instead
  # push:
  #   branches:
  #     - main

jobs:
  deploy:
    name: 🎉 Deploy to your_domain
    runs-on: ubuntu-latest

    steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v4

      - name: 📂 Sync files via FTP
        uses: SamKirkland/FTP-Deploy-Action@v4.3.5
        with:
          server: ftpupload.net # Change if using another host
          username: your_ftp_username
          password: ${{ secrets.FTP_PASSWORD }}
          server-dir: your_domain/htdocs/ # Replace with your correct path
          retries: 3
          retryDelay: 10

Deploy on Push (Optional)

To deploy automatically whenever you push to the main branch:

  • Uncomment the push block and remove or keep workflow_dispatch.

Step 4: Add FTP Password as a GitHub Secret

  1. Go to your repo > Settings > Secrets and variables > Actions.

  2. Click New repository secret.

  3. Name it FTP_PASSWORD, and paste your FTP password as the value.

This keeps your credentials safe and out of your code.


Step 5: Deploy Your Site

To Deploy Manually:

  1. Go to Actions in your repo.

  2. Select the "Deploy to your_domain" workflow.

  3. Click Run workflow.

To Deploy on Push (if enabled):

  • Just push to the main branch and it will deploy automatically!

Step 6: Confirm It Works

  • Open your hosting file manager or FTP client.

  • Check that files are appearing in htdocs (InfinityFree) or public_html (cPanel).

  • Visit your domain to see your updated site.


Additional Tips

  • Change server-dir if you're not using htdocs (InfinityFree default) or public_html (cPanel).

  • Use branch filtering or add additional jobs if you want to deploy different branches to staging or production.

  • If deploying a static site like HTML/CSS/JS, you’re good to go. If using frameworks like Laravel, consider build steps and .htaccess.


Troubleshooting

IssueSolution
FTP errorCheck if your FTP server, username, and password are correct
Files not appearingDouble-check server-dir and that upload completed successfully
GitHub Action failedClick the failed job to see logs; review credentials and directory paths

Final Notes

  • Replace all instances of your_domain with your actual domain name (e.g., myblog.infinityfreeapp.com).

  • Avoid committing sensitive information like passwords — use GitHub Secrets instead.

  • Automating deployments saves time and reduces errors — enjoy the DevOps power!


10
Subscribe to my newsletter

Read articles from Dan Ongudi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dan Ongudi
Dan Ongudi