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


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
- Visit
https://yourdomain.com:2083
(replace with your domain or hosting provider’s cPanel login page).
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 subfolderQuota: 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
- Go to the Client Area and log in.
2. Get FTP Details
Under My Accounts, select your domain and click Manage.
Scroll down to FTP Details and copy:
FTP Server (e.g.,
ftpupload.net
)FTP Username
FTP Password
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 keepworkflow_dispatch
.
Step 4: Add FTP Password as a GitHub Secret
Go to your repo > Settings > Secrets and variables > Actions.
Click New repository secret.
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:
Go to Actions in your repo.
Select the "Deploy to your_domain" workflow.
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) orpublic_html
(cPanel).Visit your domain to see your updated site.
Additional Tips
Change server-dir if you're not using
htdocs
(InfinityFree default) orpublic_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
Issue | Solution |
FTP error | Check if your FTP server, username, and password are correct |
Files not appearing | Double-check server-dir and that upload completed successfully |
GitHub Action failed | Click 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!
Subscribe to my newsletter
Read articles from Dan Ongudi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
