Automate PHP App Deployment to InfinityFree with GitHub Actions

Automate PHP App Deployment to InfinityFree with GitHub Actions

6.1K views
Summary
Learn how to set up a seamless CI/CD pipeline to deploy your PHP application on InfinityFree using GitHub Actions. This guide walks you through configuring FTP credentials, adding GitHub secrets, writing a deploy workflow, and handling server-side changes effectively. Perfect for developers seeking automatic, free hosting deployment directly from GitHub to InfinityFree.

CI/CD Deployment of PHP App to InfinityFree using GitHub Actions

Hi Guys My Name is Akash Vishwakarma In this article we will use Github Action to deploy php project using ftp credentials

Deploying your PHP app to InfinityFree using GitHub Actions lets you automate your workflow using CI/CD. This guide shows how to set up automatic FTP deployment when you push code to your repository.

1. Get InfinityFree FTP Credentials

Login to your InfinityFree control panel and find these details under FTP Accounts:

  • FTP Host: e.g., ftpupload.net
  • FTP Username: e.g., epiz_12345678
  • FTP Password: Your hosting account password
  • FTP Port: 21

2. Add Secrets to GitHub

In your GitHub repo, go to Settings → Secrets → Actions and add the following:

  • FTP_HOST
  • FTP_USERNAME
  • FTP_PASSWORD
  • FTP_TARGET_FOLDER (e.g., /htdocs/)

3. GitHub Actions Workflow

Create a file at .github/workflows/deploy.yml:

name: 🚀 Deploy PHP App to InfinityFree via FTP

on:
  push:
    branches:
      - main

jobs:
  ftp-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 📥 Checkout code
        uses: actions/checkout@v3

      - name: 📤 FTP Deploy
        uses: SamKirkland/FTP-Deploy-Action@v4.3.5
        with:
          server: ${{ secrets.FTP_HOST }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          server-dir: ${{ secrets.FTP_TARGET_FOLDER }}

4. .ftpignore File

To exclude unnecessary files, add a .ftpignore file:

.git/
.github/
.gitignore
README.md
LICENSE
*.md

5. What If You Edit Files on the Server?

InfinityFree only allows FTP access — it can’t sync changes back to GitHub. If you make changes directly on the server:

  1. Use FileZilla to download the updated file from /htdocs/.
  2. Replace or update your local GitHub files.
  3. Run git add ., git commit -m "Sync from server", and git push.

6. Best Practice

To avoid sync issues:

  • Edit code locally or in GitHub.
  • Use GitHub Actions to deploy.
  • Never manually edit files on InfinityFree unless absolutely necessary.

That's it! You've set up a working CI/CD deployment pipeline for your PHP project using GitHub Actions and InfinityFree.