Deploying Laravel projects to shared hosting manually β via tools like FileZilla β can be time-consuming, error-prone, and inefficient. I recently faced this challenge while managing multiple Laravel projects (including a school management system) and decided to finally automate the process.
In this post, Iβll share how I automated my deployment pipeline using GitHub Actions + FTP, even on a shared hosting environment (like cPanel or DirectAdmin) β no SSH access needed!
π§± The Problem
Manually deploying files via FileZilla was:
Slow (uploading file-by-file)
Risky (easy to miss files or overwrite the wrong thing)
Time-consuming (especially during multiple updates per day)
β
The Goal
I wanted a solution where:
Code is automatically deployed when I push to main
I can avoid uploading node_modules/, vendor/, or .env
No SSH is required
It's easy to set up and secure
π§ The Stack
Laravel (PHP framework)
GitHub for source control
GitHub Actions for automation
FTP access (via DirectAdmin or cPanel)
π The Solution: GitHub Actions + ftp-deploy Action
Step 1: Set FTP Credentials as GitHub Secrets
In your GitHub repo:
Go to Settings > Secrets > Actions
Add:
FTP_HOST = ftp.yourdomain.com
FTP_USERNAME = your FTP username
FTP_PASSWORD = your FTP password
FTP_TARGET_DIR = /public_html/your-laravel-folder/ (dont't forget the / at the end of your path)
Step 2: Create Your GitHub Action Workflow
In .github/workflows/ftp-deploy.yml:
name: π FTP Deploy Laravel App
on:
push:
branches:
- main
jobs:
ftp-deploy:
name: Deploy via FTP
runs-on: ubuntu-latest
steps:
- name: π₯ Checkout code
uses: actions/checkout@v3
- name: π FTP Deploy
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
with:
server: ${{ secrets.FTP_HOST }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./
server-dir: ${{ secrets.FTP_TARGET_DIR }}
exclude: |
**/.git*
**/.env
**/node_modules/**
**/vendor/**
**/tests/**
storage/
dry-run: false
π¬ Conclusion
This solution saved me hours of manual work. Now, I simply push to main, and the code is live. If you're stuck using shared hosting without SSH, GitHub Actions + FTP is a reliable and modern way to automate your Laravel deployments.
Let me know if you try it or need help setting it up!
Top comments (0)