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 domainFTP_USERNAME
β Your FTP usernameFTP_PASSWORD
β Your FTP passwordFTP_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:
- GitHub Actions fetches the latest code
- Installs Node dependencies
- Builds your project (processes assets)
- 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
andSHOW_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.