Keeping your code inside a version control system like GitHub and automatically deploying changes is widely known as the best way to maintain a stable site. Because of this, we've made it easy to integrate your WordPress site with Buddy.
In this article, we'll show you how to integrate your Pagely VPS with Buddy for automatic deployments.
Initial Setup
Always Test on a Staging Site First
Just like setting up any other deployment process, invalid configurations, typos, and other problems are always possible. In case anything goes awry, always test automatic deployments on a staging site before targeting a live site in production.
Setting Up Your GitHub Repository
When setting up a repository that will use automatic deployments, it's important that it correctly matches the environment that you'll be deploying to. If your WordPress site's files differ from what's inside version control, you could lose data when the deployment runs.
If you'd like to learn more about structuring your repository, excluding files, and how automatic deployments work, take a look at our article about setting up Git repositories for automatic deployments.
Creating a New Integration in Atomic
To communicate between your Pagely account and 3rd-party services, Pagely offers an integration interface. These integrations allow you to easily generate credentials for 3rd-party services in just a few clicks.
Further sections in this article assume that you've already created an integration inside Atomic. To learn more, take a look at our article on creating a new integration inside the Atomic control panel.
Connecting the repository and creating a pipeline
- After you login into Buddy, create a new project by clicking on the New project button:
- Next, you will connect your git repository. To do so, you should follow the relevant tutorial:
- Once you've connected your git repository, its time to create your first pipeline. Pipelines are simply a set of actions you want to execute each time a trigger is met. To add a new Pipeline, click the New pipeline button.
- Add the name (eg. "Deploy to production").
- Pick the trigger (manual, on code change, or on schedule).
- Pick the branch.
Setting Up Your Integration Secret Key in Buddy
Storing your integration secret as a variable in Buddy prevents your key from displaying inside your logs or action pipelines. For security, it's always a good idea to put your integration's deploy tokens, or any other sort of credentials, inside a Buddy variable.
In Buddy, variables can have different scopes:
- workspace-wide - accessible for every project, pipeline and action.
- project-wide - accessible for every pipeline and action in that project.
- pipeline-wide - accessible for every action in the given pipeline.
- action-wide - accessible only in the given action.
We recommend setting Integration Secret as a project-wide variable. To add it:
- Go to you project and click the Variables, Keys & Assets in the sidebar.
- Click Add... and select Add variable.
- Set the name as PAGELY_INTEGRATION_SECRET and fill the value with the Integration Secret that was generated for you in Atomic.
- Make sure the encrypted checkbox is checked.
- Press the Add this variable button.
Creating a Deployment pipeline
To ensure deployments from Buddy can be as seamless as possible, Pagely provides a Docker image that is ready to be used with just a few variables, doing the rest of the work for you.
- In your pipeline, add a new action by clicking the Add action button.
- Next, find the Custom Build action. Here, you will need to add something in the commands section, as it cannot be blank. We recommend adding a comment, such as
#Pagely Deployment
. - You will also need to change the docker image to use the
pagely/pagely-vps-deploy
. - Lastly, you will add the rest of the variables in the Variables tab:
Remember to set up the:PAGELY_APP_ID
PAGELY_DEPLOY_DEST
PAGELY_INTEGRATION_ID
If your code is located inside of a separate source directory, you can set it withPAGELY_WORKING_DIR
. This is helpful if you're performing other build steps that place your production-ready code in a different location. - The only thing left is to press the Run button to deploy your code:
As always, if you have any further questions that we weren't able to cover here, reach out to Pagely support at any time.
Related Steps
If there are actions you need performed on the server after a deployment is run, please refer to our guide on running additional scripts after an automatic deployment.
Also, check out other Buddy guides to see how else you can leverage Buddy in your deployments.