CI/CD Deployment with GitHub Actions

Prisma PHP supports continuous deployment via GitHub Actions. This method automates the deployment process whenever you push changes to the main branchβ€”making updates fast, consistent, and hands-free.

πŸš€ GitHub Actions Workflow File

Create a file at .github/workflows/main.yml and paste the following content:

on:
  push:
    branches:
      - main

name: πŸš€ Deploy website on push

jobs:
  web-deploy:
    name: πŸŽ‰ Deploy
    runs-on: ubuntu-latest

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

      - name: 🧰 Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: πŸ“¦ Install dependencies
        run: npm install

      - name: πŸ› οΈ Build project
        run: npm run build

      - name: πŸ“‚ Sync files to server
        uses: SamKirkland/FTP-Deploy-Action@v4.3.5
        with:
          server: ${{ secrets.FTP_SERVER }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          server-dir: ${{ secrets.FTP_SERVER_DIR }}

πŸ” Setup Secrets in GitHub

Navigate to your repository's Settings β†’ Secrets and variables β†’ Actions and add the following secrets:

  • FTP_SERVER – Your FTP server IP or domain
  • FTP_USERNAME – Your FTP username
  • FTP_PASSWORD – Your FTP password
  • FTP_SERVER_DIR – Remote directory (e.g., / Or /directory_name/)

πŸ“¦ Project Structure Before Deploy

Before pushing to GitHub, ensure your project is structured correctly and optimized for deployment.

Prisma PHP Project
β”œβ”€β”€ .github/workflows/main.yml
β”œβ”€β”€ prisma/
β”œβ”€β”€ settings/
β”œβ”€β”€ src/
β”œβ”€β”€ vendor/
β”œβ”€β”€ .env
β”œβ”€β”€ .htaccess
β”œβ”€β”€ bootstrap.php
β”œβ”€β”€ composer.json
β”œβ”€β”€ composer.lock
β”œβ”€β”€ package.json
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ postcss.config.js
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ [... other core files ...]

πŸ“ˆ How It Works

Once you push code to the main branch:

  1. GitHub Actions fetches the latest code
  2. Installs Node dependencies
  3. Builds your project (processes assets)
  4. Deploys files via FTP to your production server

βœ… Best Practices

  • Only include production-ready files in the repo (exclude node_modules)
  • Use APP_ENV=production and SHOW_ERRORS=false in your .env
  • Protect your .env file from public access

This setup ensures a modern, automated CI/CD workflow for Prisma PHP with minimal configurationβ€”ideal for fast iteration and stable delivery.