Continuous integration catches broken PHP, standards violations and failing tests before users see them. For WordPress plugins a small GitHub Actions workflow covers most of it.

WordPress plugin CI pipeline: lint, coding standards, tests, build zip, release
Lint, standards, tests, build, release.

From my own work: All of my open-source WordPress and PHP projects on GitHub run this kind of pipeline. Adding PHP lint across versions alone has caught real syntax incompatibilities, such as code that needed PHP 8.2 running in an 8.1 job.

.github/workflows/ci.yml

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php: ['8.1', '8.2', '8.3']
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          tools: composer
      - run: composer install --no-progress
      - name: PHP lint
        run: find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 php -l
      - name: Unit tests
        run: vendor/bin/phpunit
  standards:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with: { php-version: '8.3', tools: composer }
      - run: composer install --no-progress
      - run: vendor/bin/phpcs

setup-php installs any PHP version; the WordPress Coding Standards ruleset plugs into PHPCS via Composer.

phpcs.xml.dist

<?xml version="1.0"?>
<ruleset name="My Plugin">
  <file>.</file>
  <exclude-pattern>vendor/*</exclude-pattern>
  <rule ref="WordPress"/>
  <config name="minimum_wp_version" value="6.4"/>
  <config name="testVersion" value="8.1-"/>
</ruleset>

Tests without WordPress

Keep business logic in plain PHP classes so PHPUnit can test it without loading WordPress. Use the WordPress test suite (or wp-env) only for integration tests.

Release zip on tags

on:
  push:
    tags: ['v*']
jobs:
  release:
    runs-on: ubuntu-latest
    permissions: { contents: write }
    steps:
      - uses: actions/checkout@v4
      - run: composer install --no-dev --optimize-autoloader
      - run: rsync -a --exclude-from=.distignore ./ build/my-plugin/ && cd build && zip -r ../my-plugin.zip my-plugin
      - uses: softprops/action-gh-release@v2
        with: { files: my-plugin.zip }

Tips

  • Use .distignore to keep tests and dev files out of the zip.
  • Fail the release if the tag doesn’t match the plugin header version.
  • Cache Composer to speed up runs.

Workflow syntax reference: GitHub Docs. Local setup: Docker for WordPress.

Want this done on your own server or site?

I am Saizul Amin, a web developer and technical SEO consultant. I set up and harden VPS servers, migrate WordPress sites, fix indexing problems and build automations. See my portfolio or get in touch.

FAQ

Do I need Composer for a simple plugin?

Not to run it, but Composer makes PHPCS and PHPUnit easy to install in CI.

Should CI block merges on PHPCS warnings?

Start with errors only, then tighten as the codebase gets cleaner.

Can I deploy to WordPress.org from GitHub Actions?

Yes, with an SVN deploy action and your WordPress.org credentials stored as secrets.

Sources

NEW BLOGS. REAL STRATEGIES. REAL RESULTS.

Join our community and receive powerful SEO tips, web optimization guides, and growth strategies as soon as they’re published.

Don’t just read blogs — stay ahead of the competition.

We don’t spam! Read our privacy policy for more info.

Share.
Leave A Reply