Skip to content

WordPress Plugin CI

Reusable continuous integration pipeline for WordPress plugins. Runs PHP code quality checks and optionally builds and lints the front-end (TypeScript/Vite).

Trigger

yaml
on:
  workflow_call:

Called via uses: from the plugin repository's CI workflow.

Inputs

InputTypeDefaultDescription
php-versionsstring'["8.3", "8.4"]'JSON array of PHP versions for the matrix
node-versionstring'22'Node.js version for UI builds
has-uibooleanfalseEnable build of the ui/ directory with npm
has-testsbooleanfalseRun composer test
has-phpstanbooleantrueRun composer check:stan (PHPStan)
has-cs-fixerbooleantrueRun composer check:style (PHP CS Fixer)
has-rectorbooleanfalseRun composer check:rector (Rector)
php-extensionsstring'mbstring, xml'PHP extensions to install
needs-github-app-authbooleanfalseGenerate GitHub App token for private Composer repos (e.g. my-package)

Secrets

Required only when needs-github-app-auth: true:

Secret / VariableTypeDescription
PRIVATESATIS_BOT_APP_IDorg variableGitHub App ID for privatesatis-bot
PRIVATESATIS_BOT_PRIVATE_KEYorg secretGitHub App PEM private key

Jobs

php — PHP Matrix

Runs on ubuntu-latest for each PHP version in the matrix:

  1. Checkout the code.
  2. Generate GitHub App token (if needs-github-app-auth).
  3. Configure Composer/Git auth for private repos (if needs-github-app-auth).
  4. Setup PHP with the configured extensions.
  5. Install Composer dependencies (composer install --no-interaction --prefer-dist).
  6. Check code stylecomposer check:style (if has-cs-fixer).
  7. PHPStancomposer check:stan (if has-phpstan).
  8. Rectorcomposer check:rector (if has-rector).
  9. Testscomposer test (if has-tests).

ui — UI Build

Runs only if has-ui: true:

  1. Checkout the code.
  2. Setup Node.js with npm cache pointing to ui/package-lock.json.
  3. Install dependenciesnpm ci in the ui/ directory.
  4. Type checknpx tsc --noEmit.
  5. Lintnpm run lint.
  6. Buildnpm run build.

Usage example

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

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

jobs:
  ci:
    uses: middag-io/.github-private/.github/workflows/wp-plugin-ci.yml@workflows-v1
    with:
      has-phpstan: true
      has-cs-fixer: true
      has-tests: true
      has-ui: true
      needs-github-app-auth: true
    secrets: inherit

Minimal configuration (no UI, no tests)

yaml
jobs:
  ci:
    uses: middag-io/.github-private/.github/workflows/wp-plugin-ci.yml@workflows-v1
    secrets: inherit

The defaults already enable PHPStan and CS Fixer.

MIDDAG Tecnologia