This repository contains multiple reusable GitHub Actions workflows with distinct purposes. Each workflow can be called independently or chained together, depending on the project needs.
- Centralized build and release process.
- Multi-version PHP testing.
- Safe folder synchronization with configurable mappings.
- Reusable across multiple projects.
Packages the project into a zip and publishes a GitHub release. Specifically designed for WordPress projects using @wordpress/scripts.
| Name | Description | Required | Default |
|---|---|---|---|
output_dir |
Directory where build artifacts and the zip file are placed | No | build |
| Name | Description |
|---|---|
package_file |
Name of the zip file generated by the build job, used in the release job |
- npm Scripts: Must include
"plugin-zip": "wp-scripts plugin-zip". - Dependencies: Requires
@wordpress/scriptsindevDependencies. - Engines: Must specify
nodeandnpmversions inpackage.json. - File Selection: The zip contains files declared in the
filesfield ofpackage.json.
The final zip file name is formed as: <package-name>-<version>.zip
<package-name>: fromnameinpackage.json.<version>: from Git tag (GITHUB_REF_NAMEwithoutv).
jobs:
call_shared_release:
uses: WritePoetry/reusable-workflows/.github/workflows/release.yml@v1
with:
output_dir: 'custom-build-folder'
permissions:
contents: write
packages: read
actions: read
secrets: inherit
Runs PHPUnit tests across multiple PHP versions, with optional WordPress integration testing and coding-standards checks.
| Name | Description | Required | Default |
|---|---|---|---|
php_versions |
JSON array of PHP versions used for matrix testing | No | ['7.4', '8.0', '8.1', '8.2'] |
phpunit9_config |
PHPUnit 9-specific configuration file, used only when detected | No | phpunit-9.xml |
- A valid
composer.jsonincluding PHPUnit (and optionally WPCS). - The script
bin/install-wp-tests.shfor WordPress integration tests.
- Matrix Testing: Each PHP version runs independently.
- Database: Spins up MySQL 5.7 and prepares
wordpress_testautomatically if needed. - Multisite: Executes tests in both standard and Multisite (
WP_MULTISITE=1) environments.
jobs:
tests:
uses: WritePoetry/reusable-workflows/.github/workflows/php-tests.yml@v1
with:
php_versions: "['8.1','8.2']"
secrets: inherit
Synchronizes selected local directories to a remote server using SSH and rsync. Supports multiple folder mappings through matrix execution.
| Name | Description | Required | Default |
|---|---|---|---|
host |
Remote server host | Yes | β |
username |
SSH username for the remote server | Yes | β |
folder |
Base folder on the remote server where synchronization occurs | Yes | β |
paths |
JSON array of {from, to, exclude} mappings |
No | Default WordPress structure |
| Name | Description | Required |
|---|---|---|
ssh-key |
Private SSH key for rsync authentication | Yes |
jobs:
deploy_files:
uses: WritePoetry/reusable-workflows/.github/workflows/sync-folders.yml@v1
with:
host: example.com
username: deploy
folder: /var/www/html/wp-content
paths: |
[
{"from": "themes", "to": "/themes/"},
{"from": "plugins", "to": "/plugins/", "exclude": ".git* node_modules"}
]
secrets:
ssh-key: ${{ secrets.SERVER_SSH_DEPLOY_KEY }}
You can chain these workflows to create a complete CI/CD pipeline:
jobs:
run_tests_first:
uses: WritePoetry/reusable-workflows/.github/workflows/php-tests.yml@v1
secrets: inherit
call_shared_release:
needs: run_tests_first
uses: WritePoetry/reusable-workflows/.github/workflows/release.yml@v1
permissions:
contents: write
packages: read
actions: read
secrets: inherit
Note: Artifacts are transferred between jobs using
upload-artifactanddownload-artifact. Output variables are used only to reference filenames, not to transfer files.