0Pricing
PHP Academy · Lesson

CI/CD with GitHub Actions

Test and deploy PHP automatically on every push.

CI/CD for PHP

Every push should be tested, linted, statically analyzed, and — when green on the main branch — built into an image and deployed. GitHub Actions runs this pipeline on managed runners triggered by repo events.

We'll build a workflow that runs PHPUnit on a real MySQL service, caches Composer, runs PHPStan, builds a Docker image, and deploys.

Workflow Anatomy

A workflow lives in .github/workflows/*.yml. It has on: triggers, one or more jobs:, and each job has steps:. Jobs run on isolated runners in parallel unless linked by needs:.

name: CI
on:
  push:
    branches: [main]
  pull_request:

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

All lessons in this course

  1. Containerizing a PHP Application
  2. Multi-Stage Builds and Optimization
  3. Docker Compose for Local Stacks
  4. CI/CD with GitHub Actions
← Back to PHP Academy