Automate Drupal core, plugin and theme updates on Pantheon with Terminus, CircleCI, Drush, BackstopJS and Slack.
This script will:
- Authenticate with Terminus via machine token
- Delete the multidev environment
update-dr
- Recreate the multidev environment
update-dr
- Deletion and recreation is done to clear any existing changes and pull the latest database/files from the live environment
- Switch the multidev environment
update-dr
to Git mode - Apply Pantheon upstream updates
- Drupal core updates are managed in the upstream
- Switch the multidev environment
update-dr
to SFTP mode - Check for and apply Drupal plugin updates via Drush, if available
- Check for and apply Drupal theme updates via Drush, if available
- If no Drupal updates are available the script will complete and report the Slack
- Use BackstopJS to run a visual regression test between the live environment and the multidev environment
- If discrepencies are found the script will fail and report the error to Slack
- Merge the multidev environment with the dev environment
- Deploy the dev environment to the test environment
- Deploy the test environment to the live environment
- Post a success message to Slack
- Create a CircleCI project
- Add environment variables to CircleCI for the following:
SITE_UUID
: The Pantheon site UUIDTERMINUS_MACHINE_TOKEN
: A Pantheon Terminus machine token with access to the siteSLACK_URL
: The Slack incoming webhook URLSLACK_CHANNEL
: The Slack channel to post notifications to
- Add an SSH key to Pantheon and to the CircleCI project.
- Update the site UUID in the
.env
file - Update scenarios in
backstop.js
with URLs for pages you wish to check with visual regressionurl
refers to the live URL andreferenceUrl
refers to the same page on the Pantheon multidev environment
- Ping the CircleCI API at the desired frequency, e.g. daily, to run the script
This workflow assumes the master
branch (dev) and test environments on Pantheon are always in a shippable state as the script will automatically deploy changes from dev to test and live.
All incomplete work should be kept in a Pantheon multidev environment, on a separate Git branch.
Inspired by Andrew Taylor whose work on automatic updates for WordPress this project is based and Kyle Hall who brought joy and delight to Drupal utilizing Terminus 1.0.