Introduction
WordPress has long been a popular choice for web development projects. In the traditional approach, a WordPress project included the entire WordPress core, along with all the necessary plugins and themes. This codebase was typically deployed using (S)FTP or checked into a source code management (SCM) system and then moved to the hosting servers via a continuous integration (CI) tool.
Automatic Background Updates were introduced in WordPress 3.7 to streamline updates for the core, plugins, themes, and translation files. While automation is desirable, the in situ update approach creates challenges. For projects with code repositories, updates can quickly render the codebase obsolete, requiring manual management of updates alongside the repository. On the other hand, relying solely on FTP for updates poses significant risks. These issues can spiral into a development nightmare.
Many hosting solutions, like Platform.sh, enforce read-only filesystems during runtime for security and reproducibility reasons. This approach aligns with version control and infrastructure definition practices. However, it clashes with WordPress’s automatic updates, necessitating potential disablement on read-only file systems.
Bedrock, combined with Composer and WordPress Packagist, modernizes WordPress development. This approach offers better version control and process repeatability. Chad’s article showcases how this can lead to automated updates, providing greater control over WordPress projects.
This article goes further by demonstrating how Platform.sh, in conjunction with other tools, can create a modern WordPress development workflow. This workflow encompasses auto-updates while offering advanced configuration and control. It utilizes a Platform.sh template derived from a composer-based WordPress template.
The template accommodates two sites built on WordPress.org, supporting a rudimentary “distro.” These sites are deployed on Platform.sh in a Multi-App setup, with their entire codebase managed through Composer. Dependencies are automatically upgraded using Dependabot, and Dependabot pull requests are automatically merged by Mergify upon successful builds. Additionally, new code is deployed to production automatically upon PR merge. Redis and Cloudflare enhance caching and content delivery, while GitHub Actions provide additional CI/CD and Cron Scheduler capabilities.
Distros, or install profiles, streamline default installation configurations, a feature lacking in WordPress core. Automation of the initial deployment is achieved through a bespoke section in the composer.json file and a script that leverages this information. This approach eliminates the need for manual setup, providing a fully installed WordPress application.
The deployment script also handles database updates, ensuring the database schema is up-to-date after code updates. This automates a crucial but often manual task in WordPress core updates.
Dependabot is used to monitor and update dependencies in both the Italian and English apps. Dependabot configurations ensure periodic dependency checks with a limit on the number of open pull requests. This setup helps maintain up-to-date dependencies.
Automated pull requests issued by Dependabot are efficiently managed using Mergify. Mergify is configured to automatically squash-merge PRs that meet specific criteria. This setup ensures that code updates do not clutter the repository and are automatically merged when deemed safe.
The combination of Dependabot, Mergify, and Platform.sh offers precise control and assurance over automated updates for WordPress core, plugins, themes, and translation files. This workflow ensures that every update is thoroughly tested in a live-like environment before deployment. It allows fine-grained control over update types, exclusion of specific items, and much more.
This workflow can be extended to accommodate various scenarios, including auto-merging different types of PRs and applying automation to other types of applications, not limited to WordPress. Additionally, automating infrastructure upgrades is a promising avenue for future development, offering even more efficiency and control.
While awaiting the potential for infrastructure auto-upgrades, you can begin using this template and workflow now. It will save valuable development time and enhance your team’s efficiency.
© 2013 - 2024 Foreignerds. All Rights Reserved