WordPress is the most popular content management system on the web, with a CMS market share of 64.3%, and powering over 35 million websites around the world.
Keeping track of a large WordPress site can be a complex and time-consuming process. However, by using Git, a version control software, developers can streamline their workflow.
Git has become an integral part of modern web development, with 93% of developers using it in their projects, according to a recent survey by Stack Overflow.
By leveraging the power of Git with tools such as RunCloud, developers can simplify the deployment process, reduce the risk of errors, and save both time and resources.
Whether you’re a freelance developer or part of a larger team, automating your WordPress deployments with Git is a smart and efficient choice.
In this article, we will show you how to use RunCloud’s Automatic Deployment functionality to create a streamlined workflow.
Note: Before we get started, make sure you have a website stored on one of the supported git providers, and a server connected to RunCloud.
Creating A Web Application
You’ll need to clone your website to RunCloud before we can configure automatic deployments. To do this, go to your RunCloud dashboard and switch over to the “Git Repository” tab and select the git provider where your code is hosted.
Give your application a suitable name, and select whether you want to use an existing user or create a new one.
Note: if you plan to host multiple git repositories, you will need to have a separate owner for each repository, otherwise you will get a “Key already in use” error at a later stage.
Next you will need to specify the domain name that you want to use. If you don’t have a domain yet but want to follow along with this tutorial, you can use the test domain provided by RunCloud.
After specifying the domain name, scroll down to the git section. In the Repository field, enter your git username, followed by a “/”, and then the name of the repository.
In the Branch field, enter the name of the branch that you want to deploy. For example, if the URL of your repository is “https://github.com/tatticoder/my-wp-site” then you need to enter “tatticoder/my-wp-site” in the repository field.
Next, you’ll need to configure the deployment key. If you don’t have a deployment key, click on “Generate key” and it will generate a new key for your current user. You’ll then need to add the deployment key of this RunCloud user to your git server.
This is a straightforward process. Go to your git repository and open the “Settings” tab. Look for the “DeploymentKeys” menu and click on “Addkey”. Now paste the key that was shown in RunCloud dashboard and click “Save”.
After you have added the key, you should see it in your git dashboard. Now, you can go back to the RunCloud dashboard and continue the rest of the setup.
You can specify where you want to automatically backup your site or select the PHP version that you want to use.
Once you have made all the necessary changes, click on “Deploy” to finish the setup.
Configuring Atomic Deployment on RunCloud
After adding the web application to your server, you can take advantage of RunCloud’s Atomic Deployment functionality. This streamlines your website management process, and automatically updates your website whenever you push a commit to git repository.
To configure Atomic deployment, go to RunCloud dashboard and look for “Atomic Deployment” in the left submenu. Now, click on “Add New Project” to get started.
The setup process is super simple, and takes only a couple of seconds – you only need to provide a descriptive name for the project and specify the application that you want to deploy. Once you click “Save”, your web application will be converted to use Atomic deployment.
Note: The dropdown menu will only list web applications that are currently deployed on your server via git. If you don’t see your application in the list, make sure you completed the creating a web application step successfully.
After you have created a web application project, you will need to add a Webhook to your git server – this notifies RunCloud when a change has been made to your application.
To configure a webhook, open the “Project info” page in RunCloud – you will see a webhook URL. Copy that URL and go to your git server. Open the “Settings” tab of your repository and look for the “Webhooks” menu.
In the webhook section, create a new webhook, and paste the URL that we copied earlier into the payload URL field. Change the content type to “application/json” and make sure that push event will trigger the webhook. Click on “Add” to finish the setup.
Testing the Deployment
Once you have added the webhook, RunCloud will be notified about any changes made to your web application, and will automatically update the live website.
To test this, make a small change to your website. Once you commit and push the changes to the right branch, it will trigger a webhook event.
You can verify whether this event was successful by hovering over the webhook URL on your git server:
When an event is delivered to RunCloud, the Atomic deployment will automatically fetch all the new changes, try to build a new copy of the website, and publish it on the server.
You can see the number of failed and successful deployments in the Atomic Deployments dashboard:
If a deployment is failing for any reason, you can see its build logs by clicking on the name of the deployment, and use these to identify which step is failing – and act accordingly.
Using Git to automate WordPress deployments saves time and allows multiple developers to work on the same codebase. RunCloud’s Atomic Deployment functionality simplifies the deployment process by automatically pushing the changes to the live server –reducing the risk of errors and downtime.
If you’re tired of managing your own servers – you might want to check out RunCloud (yep, that’s us!). RunCloud is built for developers that want to focus on shipping great work, not on managing their infrastructure.
Discover what a painless server configuration feels like, allowing you to avoid having to spend hours figuring it out. Get started with RunCloud today, and get up and running in minutes.