Upcoming event: See how our commerce options can help your business adapt to the shifting landscape at GoDaddy Open 2021 on September 28.
This week we are going to be discussing deployment workflow again. In my last article, we learned how to set up a DeployBot account and push commits from GitHub to our GoDaddy Managed WordPress server, and even have the site cache flushed automatically after each deployment.
In this article, we are going to cover all the same concepts including:
- How to set up a DeployBot account.
- Where to get your SFTP login credentials from GoDaddy.
- How to connect your Bitbucket remote repository to your DeployBot account.
- Getting your commits to auto-deploy to your GoDaddy Managed WordPress server with every “git push.”
- How to send a command to your Managed WordPress server that will automatically flush its cache after a deployment.
The only real difference is that we will be using Bitbucket, rather than GitHub, as our remote repository provider.
Either provide free as well as pro accounts. I personally have had the opportunity to use both on a regular basis for an extended period of time and find that both services perform reliably.
Let’s go ahead and jump in!
Step 1: Get your credentials & access in order
The first thing we need to do is make sure to check on your access level to the repo. For instance, if you are a collaborator on a project, make sure that the owner of the repository has given you administrative access in Bitbucket.
Also, if you have not generated an SSH key for your Bitbucket account, you will need to do so in order for DeployBot to communicate properly with your remote repository. (For more information on how to generate and add SSH keys to your Bitbucket account, refer to the Bitbucket documentation.)
Now, let’s mosey on over to your GoDaddy account and grab some credentials that we’ll need a bit further down the article.
Next, click on the Settings button of the Managed WordPress server you wish to give DeployBot access to.
Select the SSH & SFTP tab and copy your Hostname, SFTP username and password, and last but not least, click the checkbox to enable SSH.
Pro tip for Mac users: If you don’t use Flycut, you should install it right now — total game-changer.
Step 2: Connect DeployBot
After you have those items on your clipboard, your Bitbucket repository set up and have the SSH key generated, we need to go to DeployBot and register an account.
I should mention that there are varying paid accounts available — from a Basic plan (10 repositories) up to a Premium plan (50 repositories). If you need to connect more than 50 repositories, there are Enterprise options available, too.
Once you have registered, logged in, and connected your Bitbucket account, you will need to click on the “Repositories” navigation link located in the top left side of the page and select the “Connect a repository” button.
It’s now time to connect your Bitbucket repository to your DeployBot account.
Select the Bitbucket icon then your user name and then the repository you wish to update your GoDaddy Managed WordPress server with. If you would like to associate the repository with a color, you can, but it’s optional.
Once the repository has been initialized by DeployBot, go ahead and click on the repository. It will then redirect you to a page asking if you would like to create a new environment and server. After selecting that you will be directed to the “Add an Environment” page.
All you need to do here is enter the type of server you are deploying to — you can name this anything you want. Select “Automatic” and lastly, the branch of the repo with which you would like to update your server’s files.
If you are inclined to notify third-party applications such as Slack upon each deployment, you can read more about it on DeployBot’s Integration page.
Upon saving you will be prompted to select an option on how you would like your commits deployed. Given the scope of this article and that you are using GoDaddy’s Managed WordPress hosting, we are going to select SFTP.
We should now be on DeployBot’s “Add a new SFTP server” page. This is where all the magic happens.
Enter the name of your server in the name field. Next, enter your Hostname that we grabbed from GoDaddy earlier. Because we’re using SFTP we’ll need to use port 22 in the Port field.
Next, enter the destination path; this is where you want your files to go to on your server. For instance, you will be changing files to your theme or child theme so you will want to assign a path to that directory.
GoDaddy’s path should look something like this:
Now we can enter our login credentials that we copied from GoDaddy — but don’t save just yet!
3. Add a shell command to flush the WordPress cache
We can now flush the GoDaddy cache automatically post-deployment.
While still on the “Add a new SFTP server” page, scroll down to the “Run shell commands after deployment” section and enter the command:
wp godaddy cache flush
This is a special WP-CLI command provided by GoDaddy as part of your Managed WordPress server.
Select the “Save Changes” button and voila, you are another step closer to becoming the ultimate multitasking wizard!
If you run into a snag or two, never fear. Leave your comments, tips, and questions below or in the GoDaddy Community.