Automated Pipelines

CI/CD Deployment

Automate your deployment process whenever you push changes to the main branch. Make updates fast, consistent, and hands-free using GitHub Actions.

The Workflow File

Create a new file at .github/workflows/main.yml in your repository.

.github/workflows/main.yml
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 }}

GitHub Secrets

Navigate to your repository's Settings → Secrets and variables → Actions and add these secrets to keep your credentials safe.

Secret Name Description
FTP_SERVER Your FTP server IP address or domain name.
FTP_USERNAME Your FTP username.
FTP_PASSWORD Your FTP password.
FTP_SERVER_DIR Target directory (e.g., /public_html/ or /).

How It Works

Push Code

You commit and push changes to the main branch.

Action Triggers

GitHub Actions spins up a clean container.

Build & Compile

npm install and npm run build compile your frontend assets.

Deploy

The finalized files are synced to your server via FTP.

Project Structure

Ensure your repository structure matches the following to allow the action to find the correct files.

File Tree
Prisma PHP Project/
├── .github/workflows/main.yml
├── prisma/
├── settings/
├── src/
├── vendor/
├── .env
├── .htaccess
├── bootstrap.php
├── composer.json
├── package.json
├── postcss.config.js
└── prisma-php.json

Production Settings

Always set APP_ENV=production and SHOW_ERRORS=false in the .env file on your live server (not in the repo).

Security

Never commit node_modules or your local .env file. Use `.gitignore` to keep the repository clean and secure.