CI/CD Pipelines with GitHub Actions: Automate Everything
February 22, 2026
•
2 min read
•
10 views
GitHub Actions is the most popular CI/CD platform for open-source projects. It runs workflows triggered by events like pushes and pull requests — directly inside your GitHub repository.
Complete Laravel CI Pipeline
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: mbstring, pdo_mysql, redis
coverage: xdebug
- name: Cache Composer
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Install Dependencies
run: composer install --no-progress --prefer-dist
- name: Copy Environment
run: cp .env.example .env && php artisan key:generate
- name: Run Tests
env:
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_PASSWORD: secret
run: php artisan test --coverage --min=80
Deploy on Merge
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to Production
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
php artisan config:cache
php artisan route:cache
php artisan queue:restart
Combine with GitHub branch protection rules to enforce quality gates without slowing down developers.
Related Posts
Docker for Developers: From Zero to Containerized Applications
Master Docker fundamentals — images, containers, volumes, and networks — to ship consistent environments every time.
Docker Compose: Orchestrating Multi-Container Applications
Define and run multi-container applications with Docker Compose — databases, caches, queues, and your app in one command.
Kubernetes Fundamentals: Container Orchestration at Scale
Understand Kubernetes core concepts — Pods, Deployments, Services, and Ingress — to run production workloads at any scale.
Comments (0)
No comments yet. Be the first to comment!