Using a version control system for automatically deploying your WordPress site ensures that your code stays current and mitigates risks associated with manual file updates. In this article, we'll guide you through deploying your WordPress site's files using Azure Pipelines so you can keep your site up to date with the latest changes.
Initial Setup
Test in Staging 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 Azure Repos Repository
Ensure that your repository mirrors your live site. During automatic deployment, your site's files will be synchronized with your version control. If there are discrepancies between your repository and live site (such as missing plugins or themes in the repo), they will be affected after deployment. It's vital to properly set up your repository to prevent data loss.
For guidance on automatic deployments and repository setup, refer to our article on 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 a set of 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.
Setting Up Your Integration's Secrets in Azure DevOps
For security, set up your credentials and identifiers as variables within Azure DevOps.
- Log into your Azure DevOps account and navigate to the project that contains your WordPress site's repository.
- From the sidebar, go to Pipelines and then select Library.
- Select + Variable to add a new variable.
- Enter
pagely-credentials
as the name and input your Pagely credentials for the value. Make sure to select the Keep this value secret checkbox to hide the credentials. - Repeat this process for the
app-id
,integration-id
, andintegration-secret
variables using the respective values provided by your integration inside Atomic. - Select OK or Save to store the configuration and ensure all your newly added secrets are listed.
Creating a Deployment Pipeline
To get your automated deployment up and running with Azure Pipelines, you need to create a pipeline configuration in a YAML file. Here's a practical example showing how you might set up a deployment pipeline for Pagely within Azure DevOps.
# This is an example pipeline that deploys to Pagely.
trigger:
- master
pool:
vmImage: "ubuntu-latest"
variables:
- group: pagely-credentials
- name: pagely_deploy_dest
value: "/httpdocs/wp-content/plugins/example-plugin-debug"
- name: pagely_integration_secret
value: $(integration-secret)
- name: pagely_integration_id
value: $(integration-id)
- name: pagely_app_id
value: $(app-id)
- name: pagely_working_dir
value: plugins/example-plugin-debug # Path to plugin
steps:
- script: docker pull pagely/pagely-vps-deploy:1
displayName: 'Pull Pagely Deploy'
- script: docker run
-e PAGELY_DEPLOY_DEST=$(pagely_deploy_dest)
-e PAGELY_INTEGRATION_SECRET=$(pagely_integration_secret)
-e PAGELY_INTEGRATION_ID=$(pagely_integration_id)
-e INPUT_PAGELY_APP_ID=$(pagely_app_id)
-e PAGELY_WORKING_DIR=$(pwd)/$(pagely_working_dir)
-v $(pwd):$(pwd)
pagely/pagely-vps-deploy:1
displayName: 'Run Pagely Deploy'
If you're familiar with Azure Pipelines, you can take the following steps, or the whole pipeline configuration from our example, and incorporate it into your azure-pipelines.yml
file. Then, adjust the variables to fit your needs.
If this is new to you, here's how to get started:
- Begin by creating an
azure-pipelines.yml
file in your repository's root directory, or open it if you already have one. - Copy and paste our entire example pipeline configuration into your
azure-pipelines.yml
file.
- If you're already working with an existing pipeline, simply add the new steps from our example to your current setup.
- Adjust the variables:
-
PAGELY_DEPLOY_DEST: This is where you set the deployment path in Pagely. Our example uses
/httpdocs/wp-content/plugins/example-plugin-debug
, targeting a specific plugin directory. Adjust this to match the path where you need your content deployed. - PAGELY_INTEGRATION_SECRET, PAGELY_INTEGRATION_ID, PAGELY_APP_ID: These are key Pagely credentials and identifiers. You'll find these within the Atomic integration you've set up. While our example uses Azure DevOps variables, you can replace these with actual values or define them as Azure DevOps variables as per your security practices.
-
PAGELY_WORKING_DIR: This optional variable specifies the working directory for deployment. In our example, it's set to deploy from
plugins/example-plugin-debug
, which is the relative path to the plugin within your repository. Adjust it if your deployment directory differs.
-
PAGELY_DEPLOY_DEST: This is where you set the deployment path in Pagely. Our example uses
- Once you've tailored your
azure-pipelines.yml
file, give it a thorough review. When you're confident everything is correctly set up, push the changes to your Azure Repos repository. With your pipeline configuration now in place, updates to your repository will trigger the pipeline and automate the deployment of your WordPress content to Pagely.
Feel free to reach out to Pagely support if you have any questions or need assistance with your setup!