In today’s fast-paced web development world, manually deploying WordPress websites is inefficient and error-prone. Implementing a CI/CD (Continuous Integration and Continuous Deployment) pipeline can streamline development, improve code quality, and automate deployments, saving valuable time.
This guide will walk you through setting up a CI/CD pipeline for WordPress development using GitHub Actions, GitLab CI/CD, Bitbucket Pipelines, and Jenkins. Whether you’re working on a custom WordPress theme or plugin, this workflow will optimize your development process.
A CI/CD pipeline automates the process of integrating code changes and deploying them efficiently.
Start by creating a Git repository (GitHub, GitLab, or Bitbucket) and cloning it:
git clone <repo_url> cd your-wordpress-project
Organize your WordPress project. The most common approach is to track only custom themes and plugins while ignoring the core WordPress files.
wordpress-project/ │── wp-content/ │ ├── themes/ │ │ ├── my-custom-theme/ │ ├── plugins/ │ │ ├── my-custom-plugin/ │── .gitignore │── README.md
Ignore unnecessary files to keep the repository clean:
Use Git Flow or a similar branching strategy:
Example:
git checkout -b develop git checkout -b feature/add-contact-form
You can use GitHub Actions, GitLab CI/CD, Bitbucket Pipelines, or Jenkins to automate testing and deployment.
Create a .github/workflows/deploy.yml file:
name: Deploy WordPress Site
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Deploy files via FTP
uses: SamKirkland/FTP-Deploy-Action@4.3.0
with:
server: ftp.yourserver.com
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: wp-content/
server-dir: /public_html/wp-content/ Go to Settings > Secrets and add:
On a push to main, this will deploy your theme/plugin.
Create a .gitlab-ci.yml file:
Go to Settings > CI/CD > Variables and add:
Create a bitbucket-pipelines.yml file:
Create a Jenkinsfile:
Go to Manage Jenkins > Credentials and configure SSH access.
To maintain a consistent development environment, use Docker:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- "8000:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: root
WORDPRESS_DB_NAME: wordpress
volumes:
- ./wp-content:/var/www/html/wp-content
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress Run the following command:
Run:
Visit http://localhost:8000 to see your local WordPress setup.
For automated deployment:
- name: Deploy via SSH
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd /var/www/wordpress
git pull origin main
wp cache flush Setting up a CI/CD pipeline for WordPress ensures a faster, safer, and more reliable development process. Whether you use GitHub Actions, GitLab CI/CD, Bitbucket Pipelines, or Jenkins, automation will streamline your workflow.
Would you like help setting this up for AWS, DigitalOcean, or cPanel? Or do you need to hire a WordPress developer to handle the setup for you?