Bobcares

WeSupport

Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.98 minutes in June 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Automate WordPress Deployments using Buddy – How to do

by | Mar 5, 2021

Wondering how to Automate WordPress Deployments using Buddy? We can help you.

Buddy allows creating delivery pipelines with drag-and-drop actions in a visual GUI. Compared to many other CI/CD tools, Buddy requires less DevOps experience. This GUI leverages pre-configured actions like builds, test, deployments, etc

Here at Bobcares, we assist our customers to Automate WordPress Deployments using Buddy as a part of Server Management Services.

Today, let’s see how our Support Techs implement this for our customers.

Steps to Automate WordPress Deployments using Buddy

Before going into the steps we will see the prerequisites for Automating using Buddy.

1. Docker and Docker Compose installed on the local machine.
2. Git installed on the local machine.
3. Composer installed on the local machine.
4. The Yarn package manager installed on the local machine.
5. PHP version 7.2+ installed on the local machine.
6. Node.js version 14+ installed on the local machine. This article was tested on Node.js version 14.13.0, npm version 6.14.8, and PHP version 7.4.10.
7. A WordPress installation on a DigitalOcean droplet. This is where you will deploy your customized theme after building it locally.
8. A fully-qualified domain name with an A record pointed to your WordPress Droplet’s IP.
9. A DigitalOcean Personal Access Token for the API.

Installing WordPress with Docker

First, verify that Docker is running with the following command:

$ docker info

Then we can use the following command to download the latest version of the WordPress image:

$ docker pull wordpress
$ mkdir docker-wordpress-theme
$ cd docker-wordpress-theme
$ nano docker-compose.yml

Add the following definitions to the file.

version: "3.1"

services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
- ./sage:/var/www/html/wp-content/themes/sage/
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: "1"
volumes:
- db:/var/lib/mysql

volumes:
wordpress:
db:

Creating a Custom WordPress Theme

We can use the following commands:

$ cd docker-wordpress-theme
$ composer create-project roots/sage

Press 1 to select the Bootstrap framework.

Building and Launching a Custom WordPress Theme

In this step, we will install all your build dependencies, create a production build, and launch WordPress in a local Docker container.

We can use the following command:

$ cd ./sage
$ yarn add node-sass -D
$ yarn build:production

Once the build generates, exit the theme folder and launch your WordPress instance using Docker Compose:

$ cd ..
$ docker-compose up -d

Uploading a WordPress Project to a Remote Repository

Here we will upload our project to a remote Git repository that the Buddy platform can access.

We can use the following commands:

$ git init
$ git add remote https://github.com/user-name/your-repo-name.git
$ nano .gitignore

Add the following filenames:

.cache-loader
composer.phar
dist
node_modules
vendor

Save and close the file.

And then add the project under version control and commit the files to the repository on GitHub:

$ git add .
$ git commit -m 'my sage project'
$ git push

Automating with Buddy

We will start by synchronizing Buddy with the repository. In the Buddy UI, click Create a new project, select the Git provider, and choose the repository that we created earlier.

The key settings to configure are:

1.  Branch from which Buddy will deploy the code.
2.  Pipeline trigger mode.

Once we add the pipeline, we will need to create the following four actions:

1. PHP action that will install the required PHP packages.
2. A Node action that will download the dependencies and prepare a build for deployment.
3. Droplet action that will upload the build code directly to the DO Droplet.
4. An SSH action with a script that will activate your theme.

Based on the contents of the repository, Buddy will automatically suggest the actions to perform. Select PHP from the list.

Clicking the action will open its configuration panel.

Enter the following commands in the terminal section:

# navigate to theme directory
cd sage

# install php packages
composer validate
composer install

Save and run the pipeline to ensure it works.

Next, we will set Environment to node latest.

The following commands will install the necessary dependencies and perform the build.

Add them to the terminal box just like before:

# navigate to theme directory
cd sage

# install packages
yarn install

# Create production build
yarn build:production

Once again, save and run the action to ensure it works.

Next, add the Droplet action right after the Node.js build.

1. Set the Source path to sage.
2. And choose Buddy’s SSH key authentication mode as that is the easiest one to set up.

After that go back to the browser and click the Remote path browse button. The default path will be /var/www/html/wp-content/themes/sage.

Then we need to visit the Ignore paths section and provide the following to prevent uploading of Node.js dependencies:

.cache-loader/
node_modules/

Last, we will add one more action to activate the theme on the WordPress Droplet with a WP-CLI command.

On your pipeline page, add the SSH action and input the following command in the commands section:

$ sudo -u www-data -- wp theme activate sage/resources

[Need assistance? We are happy to help you]

Conclusion

To conclude, we saw our Support Techs automate WordPress deployments using Buddy.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF