Workflow Recipes
The GitHub Deployments feature on WordPress.com offers powerful customization options, including workflows for advanced deployments. In advanced mode, you can define a GitHub workflow script to process repository files before deployment. This enables tasks like enforcing coding standards, running unit tests, excluding specific files from deployment, installing dependencies, and more—giving you greater control and flexibility over your deployment process.
Below, are several workflow recipes to help you get started creating your own customized solutions.
The recipes below include example workflow scripts, which you can view by clicking the Workflow file links. Be sure to review both the scripts and the repository structure. If your repository structure differs, you may need to adjust the file paths in the workflow scripts accordingly.
Installing Composer dependencies
If your project includes Composer and you don’t want to store the vendor
folder in your repository, you can fetch your dependencies at deployment time instead.
Installing Node dependencies
If your project requires Node to bundle assets or scripts, and you don’t want to store the node_modules
folder in your repository, you can fetch your dependencies and run commands at deploy time instead.
A similar workflow can be used for deploying plugins that require a build process. See the GitHub repository example and Workflow file for this use case.
Running code checks and unit tests and failing workflow if they don’t pass
You usually only want to deploy your code once you’re sure it’s working correctly. This example shows you how to run PHPCodeSniffer and PHPUnit before creating the deployment artifact. If any of these tasks fail, the code will not be deployed.
Excluding files from deployment
There is a chance you won’t need to deploy every file in your repository. To exclude specific files, you can tell the upload-artifact action which files to include and ignore when specifying the path
value. For example, in the workflow file below, the current directory, .
, is included, but any file path starting with !
, e.g. !node_modules
, is excluded. You can download the deployment artifact and compare it to the repository contents.
It’s important to add at least one “include” pattern (usually the .
) to the workflow file so that the workflow artifact generated isn’t empty
Using Git submodule dependencies
Git allows you to nest Git repositories inside of your main repository. These are known as submodules, and this recipe shows how to use submodules in your workflow script.
Last updated: March 25, 2025