Nexcess Logo

Deploying a WordPress or WooCommerce Site with Branch

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
December 14, 2020

Branch is a Continuous Integration (CI) and Continuous Delivery (CD) tool designed around the needs of WordPress developers from the same folks behind WP Pusher. Best of all, Branch has built-in support for deploying to Nexcess!

To get started, sign up for Branch by connecting your GitHub, GitLab, or Bitbucket account, then create a site within Branch by selecting a Git repository.

Next, we’ll want to configure all of the steps necessary to build our site. Branch offers a number of “recipes” for common actions (installing Composer dependencies, running Webpack, etc.), but also gives us the ability to add any number of custom steps.

Build recipes within Branch, including npm, Composer, Grunt, Gulp, Webpack, and more

 Once we’ve outlined the steps necessary to build our site, we can move onto the next stage of our pipeline: testing.

If you have an automated test suite for your site already, you can simply tell Branch to run whatever commands are necessary. Even if you don’t already have tests, Branch makes it a breeze to add in linting, coding standards, and compatibility checks:

Build recipes within Branch, including npm, Composer, Grunt, Gulp, Webpack, and more

Now that we’ve installed our dependencies, built everything, and passed our tests, it’s time to get our code into production!

Branch contains recipes for deploying to Nexcess, and connecting the two platforms is painless:

  1. Select your site in the Branch dashboard, click “Settings”, then grab your Branch site’s public SSH key
  2. Add this public key to the list of keys within the Nexcess portal

Once Branch is able to communicate with your Nexcess site, we can select the “Nexcess” deployment recipe and fill in a few details:

  1. The hostname and username for the site (available via the Nexcess portal on your site’s “Access” screen)
  2. The web root that we’re deploying to. If our git repo is meant to serve as the wp-content/ directory, this value should be “public_html/wp-content”.
  3. The files we wish to deploy (generally the default, “*”, is sufficient)
  4. The git branch to deploy to this environment

Configuration for the Nexcess deployment recipe on Branch

The “Git branch” setting is especially important, as this lets you specify different deployments for different branches. For example, you might have a “staging” branch that deploys to your staging environment, letting you test changes before making them live.

It’s worth noting that Branch uses the continuous deployment model by default, where the pipeline runs with each push to the given branch. If you would prefer more of a continuous delivery model (where some manual action must be taken), you might consider maintaining a “production” branch that only gets merged into when you’re ready to release.

At this point, Branch should be configured to build and deploy your git repository to Nexcess! You may trigger your first deployment either by clicking the “Run Deployment” button on your site’s “Pipelines” page or by pushing to your Git repository.

Customizing your release process

One of the really nice features of Branch is the ability to configure additional steps after a successful deployment, such as automatically clearing your site’s object cache after a deployment. This can be accomplished using the WP-CLI recipe under “Other”:

The WP-CLI recipe configuration within Branch

The host and username will generally be the same as we used in the deployment step, and you can chain as many commands as necessary.

Please note that the commands will be run relative to the home directory of the SSH user, so commands should be prefixed with “--path=public_html” to avoid issues with WP-CLI not finding WordPress. For example, clearing the object cache would be “wp --path=public_html cache flush”.

Jess Frick
Jess Frick

Jessica Frick brings over 20 years of experience in the technology sector. A graduate of Rollins College, she's focused on delivering the best web applications (including WordPress, WooCommerce, Magento, and more!) to customers with the best performance possible. When she’s not obsessing about all things digital, you can find her enjoying quality time with her family, listening to music, binging a sci-fi series, working in her garden, or brewing some iced tea.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.