How to Deploy Efficiently to WP Engine Using GitLab CI/CD Pipeline in 8 Simple Steps
Last Updated: August 4, 2025

Last Updated: August 4, 2025
Efficient website deployment plays a critical role in maintaining a positive user experience and ensuring that websites stay up-to-date. Through optimizing the deployment process, we can decrease downtime and guarantee seamless and efficient implementation of changes. By integrating GitLab CI/CD pipelines with WP Engine, you can reduce errors in your deployment process. This tutorial will guide you through deploying your WordPress website to WP Engine using GitLab pipelines.
An SSH key functions as an authentication credential within the SSH protocol. Analogous to usernames and passwords, SSH keys are predominantly employed for automating tasks and facilitating single sign-on (SSO) for system administrators and power users.
To generate a new key use the following command in a terminal:
ssh-keygen -t ed25519 -f ~/.ssh/wpengine-git
After hitting enter it will ask you to set a password. Although this makes the connection even more secure, it may interrupt when setting up automated processes. Therefore, just press Enter to skip this step.

Navigate to the GitPush tab and include the developer’s name along with the SSH public key we created in the previously step. Once the developer account has been successfully added, you can verify the SSH connection by executing the following command:
ssh git@git.wpengine.com info
Note: The key will usually be published approximately 10 minutes after saving, but may take up to 45 minutes. There will be an error if you connect to Git before the key is fully published.


Access the Settings page within GitLab, then proceed to the CI/CD tab and expand the Variables section. Create a new variable with the default settings, setting the Key to SSH_PRIV_KEY and the Value to the SSH private key generated in step 1.
Make sure that your repository is configured to point to the WordPress root directory. If your repository contains WordPress within a folder, you can use the following command, where htdocs is the folder that has the WordPress root, and wpengine-main is the new branch with the content inside the htdocs folder.
git subtree split –prefix=htdocs –branch wpengine-main
WP Engine prohibits the synchronization of certain files, such as the wp-config.php file or *.exe files. Here is a .gitignore file that you can use:
# compiled files
*.com
*.class
*.dll
*.exe
*.o
*.so
*.log
# packaged files
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# ignore wp-content related
wp-content/uploads/*
wp-content/upgrade/*
#htdocs/wp-content/languages/*
# ignore translations folder
wp-content/languages/*
# specific
#.env
*.sql.gz
db_dump/
.htaccess
.DS_Store
node_modules
package-lock.json
wp-config.php
If some files are already added to your repository, you will have to remove them:
git rm –-cached path/to/your/file
git commit -m “Remove files”
After the files are removed, you can add them back if you still need them locally.
GitLab runner is a build instance that is used to run the jobs over multiple machines and send the results to GitLab which can be placed on separate users, servers, and local machines. You can register the runner as shared or specific after installing it.
Here is a guide on how to create, register, and run your own project runner.
To use GitLab CI/CD, you start with a .gitlab-ci.yml file at the root of your project. This file specifies the stages, jobs, and scripts to be executed during your CI/CD pipeline. It is a YAML file with its own custom syntax.
stages:
– deploy
.deploy:
image:
name: alpine:latest
before_script:
– ‘which ssh-agent || ( apk add –update openssh )’
– apk add –update bash
– apk add –update git git-subtree
– eval $(ssh-agent -s)
– echo “$SSH_PRIV_KEY” | ssh-add –
– mkdir -p ~/.ssh
– ‘[[ -f /.dockerenv ]] && echo -e “Host *\n\tStrictHostKeyChecking no\n\n” > ~/.ssh/config’
stage: deploy
when: manual
allow_failure: false
deploy_prod:
extends: .deploy
script:
– “git remote add wpengine git@git.wpengine.com:environment.git”
– “git push wpengine HEAD:master –force”
tags:
– wpengine
– master
– wpriders
only:
– master
environment:
name: production
url: https://domain.com
Let’s break down each command from the YML file:
Now that we have everything in place we can push some changes to our master branch. After running the deploy_prod job we should have something similar to this:

Do you like this article? Share it and send us your feedback! Check out our articles page, where you might find other interesting posts. Also, if you want to learn more about business, check out the WPRiders Blog!