Deployment script for Wordpress websites to WPEngine.
2.2K
A helper script for deploying Wordpress-based Git repositories to WPEngine via Git. WPEngine allows users to push their git repositories to their own remote servers and has the advantage of doing some of their own tests on the code before applying any code updates. However, since Git is not meant for deploying code directly to a production server, there are several issues that we faced when using this feature, namely:
docker-compose.yml, documentation, or any files that are meant to be used for local copies of the website.The script is based on joshleecreates/wpengine-deploy-script, but is a bit more generalized to fully support submodules and ignoring files. Note that the history that is pushed to WPEngine will be very different from your base repository, so you will want to avoid storing your repository only on WPEngine.
The container creates a copy of your repository to avoid any potential side-effects.
| Variable | Description |
|---|---|
WPE_REMOTE | The name of the git remote to push to. |
WPE_REMOTE_URL | (optional) The URL of the remote repo, if it does not exist in the Git repository. |
SSH_PRIVATE_KEY | (optional) The private key to use when pushing to WP Engine. You could also forward SSH_AUTH_PORT or something, but that doesn't work on Macs yet apparently. |
The wordpress repository must be located in the working directory to work correctly.
I currently bundle this in a executable, wpe-deploy, with the following:
exec docker run \
-e WPE_REMOTE="$1" \
-e SSH_PRIVATE_KEY="`cat ~/.ssh/id_rsa`" \
--volume "$PWD:/data" \
-w "/data" \
--interactive --tty --rm \
"utulsa/wpe-deploy:latest" /bin/bash -c 'source setup-ssh && run-deploy'
So if the WP Engine remote is given in the repository as production, then
wpe-deploy production
will deploy the current branch to WPEngine production.
Ignoring files on the repository to WPEngine functions identically to .gitignore; simply add a file named .wpe-gitignore to the directory where you want to start ignoring a pattern. This file will not be tracked on WP Engine.
Submodules are automatically removed in the WP Engine push, so you can use private submodules when pushing.
To set up deployments with GitLab CI, add the following to your .gitlab-ci.yml:
deploy to wpengine:
type: deploy
image: utulsa/wpe-deploy:latest
environment:
name: wpe-production
only:
- production
variables:
WPE_REMOTE_URL: <YOUR_WPE_REMOTE_URL>
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- source setup-ssh
- git submodule sync --recursive
- git submodule update --init --recursive
script:
- run-deploy
Note that you might need to change your .gitmodules file to use local addresses for submodules, and there are some open issues regarding submodules in GitLab CI.
Content type
Image
Digest
Size
14.1 MB
Last updated
over 9 years ago
docker pull utulsa/wpe-deploy