Skip to main content

CI/CD Pipeline

Overview

Automated testing and deployment pipeline using GitHub Actions.

Pipeline Stages

  1. Code Quality: Linting and formatting
  2. Testing: Unit and integration tests
  3. Build: Create production builds
  4. Deploy: Deploy to staging/production

GitHub Actions Workflow

Backend CI

name: Backend CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install Dependencies
run: |
cd backend
composer install

- name: Run Tests
run: |
cd backend
php artisan test

Frontend CI

name: Frontend CI

on:
push:
branches: [main, develop]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install Dependencies
run: |
cd frontend
npm ci

- name: Run Tests
run: |
cd frontend
npm test

Deployment

Staging Deployment

Automatically deploy to staging on merge to develop:

- name: Deploy to Staging
if: github.ref == 'refs/heads/develop'
run: |
ssh user@staging-server "cd /var/www && git pull"

Production Deployment

Manual approval for production:

- name: Deploy to Production
if: github.ref == 'refs/heads/main'
environment: production
run: |
ssh user@prod-server "cd /var/www && ./deploy.sh"

Security Scanning

- name: Security Scan
run: |
composer audit
npm audit

Notifications

Configure Slack/Discord notifications for:

  • Build failures
  • Successful deployments
  • Security alerts