Docs / Cloud & DevOps / CI/CD Pipelines with GitHub Actions

CI/CD Pipelines with GitHub Actions

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 26 views · 1 min read

What is CI/CD?

Continuous Integration (CI) automatically tests code on every push. Continuous Deployment (CD) automatically deploys tested code to production. GitHub Actions provides both, integrated directly into your repository.

Basic Workflow

Create .github/workflows/deploy.yml:

name: Deploy to Production

on:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.2"

      - name: Install dependencies
        run: composer install --no-dev

      - name: Run tests
        run: vendor/bin/phpunit

  deploy:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy via SSH
        uses: appleboy/ssh-action@v1
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            cd /var/www/myapp
            git pull origin main
            composer install --no-dev
            php artisan migrate --force

Setting Up Secrets

  1. Go to your repository → Settings → Secrets and variables → Actions
  2. Add SERVER_HOST, SERVER_USER, and SSH_PRIVATE_KEY

Best Practices

  • Always run tests before deploying
  • Use environment-specific secrets
  • Add a manual approval step for production deploys
  • Cache dependencies to speed up builds

Was this article helpful?