"Ancora Imparo" - I'm still learning (Michelangelo at 87)

CI/CD with WordPress

What is CI/CD?

Continuous integration (CI) and Continuous Delivery (CD) are a set of operating principals and best practices that allow teams to deliver changes to their applications faster and more reliably. Generally known as CI/CD or CI/CD Pipeline, this is an Agile best practice and an excellent way for teams to optimize their application deployments.

Continuous Integration

Continuous integration (CI) is the first part of CI/CD and consists of a set of best practices that enforce frequent check-in of code to version controlling repositories. This is important as many new applications consist of multiple components developed across many platforms and tools. To avoid the overheads of frequent commits and releases, CI provides ways to build and package applications quickly, so that teams can collaborate and test changes more frequently.

Continuous Delivery

Once CI is done, Continuous Delivery (CD) picks up the process and delivers new releases to relevant infrastructure through automated channels. It stores environment-specific parameters pertaining to the many environments that teams work with, such as dev, staging, and production. It then automatically pushes changes along the workflow as they are tested and accepted.

CI/CD with WordPress

One of the best things about WordPress websites is that almost anyone can manage them, despite not having any coding knowledge. Front end editors and WordPress plugins make this possible. But if your website is being updated constantly with new features and changes or a web developer who manages one or more websites of your clients, then the CI/CD process can save you a lot of time.

WordPress is no different from any other web application. It consists of code files and other static resources such as images, CSS, and JavaScript files. Introducing a CI/CD pipeline can save you time and streamline the change process.

A CI/CD Pipeline can also save you the time taken to transfer files via an FTP application like FileZilla and the additional time testing your changes and rolling them back in case of an error.

What are the tools/providers that help you with that task?

You’ll need two main types of tools to set up a CI/CD pipeline for WordPress. The first is a Version Controlling Service (VCS). This is a code repository (repo), with a few other useful features. All your code will be maintained in this repo, and you can use one of the most popular free version control services like GitHub or BitBucket, or set up your own in-house VCS.

The next step is the more important one, where you need to carefully select a CI/CD tool that suits your needs. The CI/CD tool will be triggered every time a change is made to the repo. It will process the changes, perform the necessary actions like preprocessing or packaging, and transfer the relevant files to the specified environment (Staging/Production, etc.).

Some popular options are:

Buddy CI/CD

GitLab

Branch CI

Setting up a CI/CD Pipeline for your WordPress website

This is not too difficult and requires just a few steps. Let’s look at using Buddy.

  1. Setting up Version Control
    Start by setting up your code in a VCS like GitHub. Maintain a “development” branch to commit your work in addition to the Master branch. Changes can be merged into the Master branch once they are approved.
    You will also need to disable front-end editors on WordPress, and its plugins as any changes done outside the VCS will be over-written with commits.
  1. Setup a Pipeline
    Buddy is free and quite user friendly. You can set it up with a buddy.yml file or use its GUI, which is even more intuitive. You can configure Buddy to perform many actions such as Lint PHP and JS code, preprocess CSS, and run npm commands for other frameworks.
  1. Deploying your changes
    Once all this is done, Buddy will transfer your new files to the relevant environment. A good practice is to have a separate Staging server on which you (or your clients) can verify that everything is working fine before merging changes to the Master branch and triggering an update to your Production server.
  1. Merging Database changes
    One of the more complicated parts of this process is updating your production database as it has continued to be modified in production while you made changes to a copy of it in your development environment. There are some plugins that can be used for this purpose. But you should look at setting up your own process to ensure that nothing is missed. You can read more about the complexities of this step, our solution, and some existing plugins here.
    In brief, we create a SQL or PHP script to migrate the database changes and commit it to the repo, like any other change. In addition, we maintain a migration table to ensure that no script is duplicated or repeated. We then need to add a step in our build process to execute any new migration files after all the files have been copied. This approach does require a good understanding of how WordPress code manages the database, so you should stick to a plugin if you aren’t equipped for that.

We hope you enjoyed our quick guide regarding the benefits of CI/CD for your WordPress website.

About the Autor

shanikan.wick

shanikan.wick

Shanika is a software engineer by profession. Being a graduate in Information Technology, she has gained expertise in Web development and Software testing. She is keen to share her knowledge and considers writing as the best medium to do so. She is passionate about everything she does, but apart from her busy schedule she always finds time to travel and enjoy nature. You can reach her at https://www.linkedin.com/in/shanikawickramasinghe/

Share on

Share on facebook
Share on google
Share on twitter
Share on linkedin

Liked this article?

We have a lot more where that came from!
Join the subscribers who stay ahead of the pack.

By entering your email, you agree to our Terms of Service and Privacy Policy.

Want to make your life easier?

Use Testup,  the easiest test automation tool on the web. Don’t hesitate and