📡 You're offline — showing cached content
New version available!
Quick Access
DevOps & Git Intermediate

CI/CD Pipeline: GitHub Actions Complete Guide for PHP and Python

Build CI/CD with GitHub Actions — test on every push, deploy on merge to main, matrix testing, secrets management, and SSH deploy.

EzyCoders Admin December 25, 2025 11 min read 1 views
CI/CD GitHub Actions Complete Guide
Share: Twitter LinkedIn WhatsApp

CI/CD with GitHub Actions

CI/CD automates testing and deployment. Every push triggers tests; successful merges to main automatically deploy. GitHub Actions is the most widely used platform for PHP and Python projects.

# .github/workflows/ci.yml
name: CI Pipeline

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

jobs:
  test:
    runs-on: ubuntu-latest

    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_DATABASE:      test_db
          MYSQL_ROOT_PASSWORD: root
        ports: [ "3306:3306" ]

    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          extensions: pdo, pdo_mysql

      - run: composer install --no-progress
      - run: vendor/bin/phpunit --coverage-text
        env:
          DB_HOST:     127.0.0.1
          DB_DATABASE: test_db
          DB_PASSWORD: root

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy to Production
        uses: appleboy/ssh-action@master
        with:
          host:     ${{ secrets.PROD_HOST }}
          username: ${{ secrets.PROD_USER }}
          key:      ${{ secrets.PROD_SSH_KEY }}
          script: |
            cd /var/www/ezycoders
            git pull origin main
            composer install --no-dev --optimize-autoloader
            php artisan migrate --force
            php artisan cache:clear

Q: CI vs CD?

CI (Continuous Integration): auto build and test on every push — catches bugs early. CD (Continuous Delivery): auto deploy to staging after CI passes — humans approve production. CD (Continuous Deployment): fully automated to production. Most teams: CI + CD to staging, manual production gate.

EzyCoders Admin
Written by
EzyCoders Admin

Team Lead and Full-Stack Developer with experience in PHP, JavaScript, SQL, DSA, and System Design. Passionate about software engineering, scalable web technologies, and helping developers prepare for coding interviews and tech careers through practical tutorials and professional guidance.

Comments (0)

No comments yet. Be the first!

Leave a Comment