Continuous Integration and Deployment for WordPress

Quick links

Introduction

Before diving too deep into all the jargon surrounding continuous integration and deployment (CI/CD), the first thing to say is that most of these terms are just another way of talking about “automation”. Essentially, CI/CD is the automation of your build, test and deployment processes.

Contents

Interested? Read on to learn how Branch’s CI/CD solution can help save you time and give you peace of mind when building and deploying your WordPress projects.

What is continuous integration (CI)?

Continuous integration (CI) is the process of frequently integrating new code into an existing project. This is a useful feedback mechanism that helps catch errors early.

Whether your CI pipeline runs an automated test suite or deploys to a staging site, the benefits are similar. Automated CI processes helps you check that any new work won’t break your existing code, whether you’re running manual tests, automated tests, or a mix of both.

Continuous integration with Branch

Branch offers a CI setup for your WordPress projects that runs every time you push to your Git repository.

Here are just a few of the CI tasks Branch can help you automate:

  • Pulling in dependencies from Composer and NPM or Yarn
  • Running build scripts to compile stylesheets and JavaScript code
  • Running SEO, accessibility and page speed audits
  • Scanning code for coding standards violations
  • Executing unit tests
  • Deploy to a staging or development site for testing and Quality Assurance (QA)
  • Running browser tests against the staging site

What is continuous deployment (CD)?

Continuous deployment (CD) is the final stage in the CI/CD workflow. If you have successfully integrated your latest code into the existing codebase without any errors, then why not deploy it straight away?

Branch can help you automate your deployments, letting you release your code easily and frequently. This means no more big, scary releases and less room for error.

In real life though, and especially in the WordPress world, it might not seem so simple — you might not want to deploy the latest version of your project straight to production on each commit.

Instead, you might want to first deploy to a staging or development site. Many WordPress hosting platforms recommend this kind of workflow: first deploying code to a development environment, then to staging, before finally deploying to the live production environment.

Continuous deployment with Branch

Branch’s automated deployment tasks can help you maintain a stable, up-to-date working environment, regardless of whether that’s on staging or production. This is a great way to share the progress of a project with clients and other stakeholders.

Whatever your deployment workflow, Branch can help make it quicker, easier and safer.

CI/CD for WordPress

Most WordPress projects don’t have a large suite of built-in unit and integration tests. For this reason, setting up CI/CD for WordPress is slightly different than it might be on a traditional software project.

When deploying new versions of their projects, most WordPress developers are often most concerned about broken HTML, regressions in page speed scores and so on. Thankfully, CI/CD lets you you automate checks for these issues.

A typical WordPress CI/CD workflow

So what would a CI/CD setup look like for a typical WordPress project? Well, it would depend on the project. For example, whether the project involved a standalone theme or a plugin, or whether it was a full WordPress site featuring a theme and several plugins. Branch supports both sides of the spectrum.

In a WordPress context, there a four different stages of a CI/CD build:

1. Build

This is where you pull in any dependencies and build your assets. For dependencies, most projects use a combination of Composer and NPM or Yarn to build their dependency tree. When it comes to build tools, Webpack, Grunt and Gulp are all popular within the WordPress community. These tools are responsible for compiling your production stylesheets and JavaScript code.

2. Test

Compared to many other developer communities, testing in WordPress is not a well-explored topic. While there are many options available, there is no one unified way that WordPress developers test their code. The truth is that most WordPress projects don’t really have any tests in place. However, you can use CI/CD to employ a number of tools to test your code, without having to write out a bunch of tests yourself. For example, with Branch you can easily set up tests to check your code against the WordPress Coding Standards.

3. Deploy

Deploying a WordPress project generally means one of three different things:

  • Deploying a plugin or theme to a WordPress site
  • Deploying a plugin or theme to WordPress.org
  • Deploying a full WordPress site

Branch supports all of the above cases.The deployment process is highly dependent on the hosting platform used. While some platforms only support SFTP, others offer a wide range of options including rsync, Git push and platform-specific tools such as Pantheon’s Terminus and WP Engine’s DevKit. To make things easier, Branch has built-in recipes for most of the big hosting platforms like WP Engine, Pantheon, Kinsta, SiteGround, Pagely and Flywheel and many others through the rsync, Git and SFTP deployment recipes. All you need to do is connect your Branch account to your hosting platform, typically using an SSH key, and select the right recipe for you.

4. Quality Assurance (QA)

When building, testing and deploying is automated, much of the corresponding QA work can also be automated. There’s a wide range of tools available for running post-deployment QA checks on your WordPress sites: from carrying out automated browser tests on staging sites, to using tools like Google Lighthouse to audit page speed, accessibility and SEO.

All WordPress projects differ widely in terms of tech stack and hosting environment and of course you know your work best. Branch gives you the freedom to pick and choose the best tools for your project.

CI/CD across different environments

One of the main challenges of working with CI/CD tools is configuring them for your different working environments.

Traditionally, although your CI tool would run all your code in a containerized environment, it would likely be your responsibility to provision that environment with all the tools you need.

Branch, however, is a specialized CI/CD tool that does this for you. It comes prepacked with different environments and recipes tailored specifically for WordPress developers.

Why use continuous integration and deployment?

There are three key reasons why CI/CD is important for developers:

  1. Automating your workflow saves you time. You can create build recipes to automatically carry out all the tasks you need every time you run git push, saving you time and effort.
  2. CI/CD helps catch bugs early. By using CI/CD, you can keep a regular check on whether your new code is compatible with your existing codebase.
  3. A good CI/CD system is essential for feedback. A solid CI/CD workflow gives you continuous feedback on the code you’re writing, answering the “Did I break something?” question continuously.

How to get started with Branch and CI/CD

Branch can help you automate your entire workflow, from the build and tests, all the way through to getting your code from your Git repository to the server.

You don’t need anything fancy to begin using CI/CD in your WordPress projects. If your code lives in a Git repository, then you have everything you need to get started.

Our guides will walk you through the entire setup, so start small and let Branch teach you as you go.

Step one: sign up to Branch

Ready to make your your build and deploy life easier? Head over to branchci.com and sign up for a free account with your GitHub, Bitbucket or GitLab account.

A free Branch account gives you 20 builds every month, with the option to upgrade to a paid plan if you need more.

» Sign up to Branch

Step two: create your CI/CD workflow

Once you’ve signed up, check out our Getting started guide for all the information you need to get your first WordPress CI/CD workflow up and running.

We also have a number of platform-specific guides to get you up and running with your hosting platform of choice.

Any questions?

Still have questions about CI/CD or how it could benefit your WordPress projects? Or maybe you have some feedback for us.

Either way, we would love to hear from you. Get in touch via the chat icon or send us an email at hi@branchci.com.

© 2018 - 2021 Branch Continuous Integration, Inc. All rights reserved.