Warning
This repo has been archived and moved here, to extend capabilities and add support for a new server.
This GitHub Action can be used to set automatic deployments using an SSH private key and rsync.
By default, the action will deploy the repository root directory, but you can optionally deploy a theme, plugin, or any other directory using the SOURCE_PATH
. Likewise, if you need to specify a different destination directory, you can do so using PUBLISH_PATH
.
After the deployment, this action will also purge your WP Engine cache and flush permalinks to ensure all changes are visible.
-
Set up your SSH key on WP Engine.
-
Create a new YML file in the directory
.github/workflows/
in the root of your repository. You can choose any name, e.g.,deploy.yml
. -
Add the following code to this new file, replacing values for
PRD_BRANCH
andPRD_ENV
accordingly.> .github/workflows/deploy.yml
name: 📦 Deploy to WP Engine on: push: workflow_dispatch: jobs: build: name: 🚩 Starting deployment job runs-on: ubuntu-latest steps: - name: 🚚 Getting latest code uses: actions/checkout@v2 - name: 🔁 Deploying to WP Engine uses: IlanVivanco/wpe-deployment-action@main env: # Deployment options. WPE_SSH_KEY: ${{ secrets.WPE_SSH_KEY }} SOURCE_PATH: '' PUBLISH_PATH: '' # You must, at least, set the production environment. PRD_BRANCH: main PRD_ENV: prodinstall # Uncomment this for setting a staging environment. # STG_BRANCH: staging # STG_ENV: stageinstall # Uncomment this for setting a development environment. # DEV_BRANCH: dev # DEV_ENV: devinstall
-
Finally, push the latest changes to the repository, the action will do the rest.
ℹ You can have multiple branches deploying to the same install by separating them with a comma, e.g.,
PRD_BRANCH: main, dev, staging
will deploy all three branches to the WP Engine production environment. Using regex here, well help you to extend this to even more branches, e.g.,main, feature(/.*)?
will deploy the main banch and also the feature or feature/anything branches.
-
Generate a new SSH key pair as a special deploy key between your GitHub Repo and WP Engine. The simplest method is to generate a key pair with a blank passphrase, which creates an unencrypted private key.
-
Add the public SSH key to your WP Engine SSH Keys configuration panel.
-
Store the private key in the GitHub repository as new GitHub encrypted secret using the name
WPE_SSH_KEY
save it —this can be customized if you change the secret name in the yml file to call it correctly—.
If you want some files to be ignored upon deployment, you can create a .deployignore
file on your source directory, adding the exclude patterns —one per line—. Blank lines and lines starting with # will be ignored.
> .deployignore
# Exclude rules
bin
composer*
dist
gulp*
node_modules
package*
phpcs*
src
vendor
Name | Type | Usage |
---|---|---|
WPE_SSH_KEY |
secrets | Authorized SSH private key for deployment. See SSH key usage. |
PRD_BRANCH |
string | Name of the branch you would like to deploy from, e.g., "main". |
PRD_ENV |
string | Name of the WP Engine Prod environment you want to deploy to. |
Name | Type | Usage |
---|---|---|
STG_BRANCH |
string | Name of the staging branch you would like to deploy from. |
STG_ENV |
string | Name of the the WP Engine Stage environment you want to deploy to. |
DEV_BRANCH |
string | Name of the a development branch you would like to deploy from. |
DEV_ENV |
string | Name of the the WP Engine Dev environment you want to deploy to. |
SOURCE_PATH |
string | Path to specify a theme, plugin, or any other directory source to deploy from. Defaults to the repository root. |
PUBLISH_PATH |
string | Path to specify a theme, plugin, or any other directory destination to deploy to. Defaults to the WordPress root directory. |
FAIL_CODE |
number | Code number to be used if the action fails (0 = success and 1 = error). Defaults to 1. |
Contributions to this action are always welcome and highly encouraged.
-
Licensed as MIT © Ilán Vivanco 2021.
-
This action is based on the work made by Alex Zuniga on GitHub Action for WP Engine Site Deployments.