A set of bash
scripts for "mass updating" sites on Pantheon using Terminus. These scripts are tooled for WordPress sites but can easily be repurposed for Drupal sites. While there is a Terminus Mass Update plugin, these scripts rely solely on base terminus commands; no additional plugins necessary. However, these scripts require setting ENVIRONMENT_VARIABLES
to store "secrets". I chose to put them in a local file that is not included in this repository. You may view a reference to it in the scripts. Directions for setting the environment variables are provided below.
- requirement: terminus
- optional: Node.js and npm for installing a local version of standard-version
npm install
There are two sets of scripts in this repo, a set for updating multiple sites and a set for updating a single site. Each set of scripts consists of three scripts, each script addressing either the dev
, test
or live
Pantheon Environments.
The following is a list of the scripts included and a brief description of each does. These scripts should generally be run in the order listed below:
-
Update
dev
update-site-dev.sh
orupdate-sites-dev.sh
Update core<site>.<dev>
:
-- check whether WordPress core updates are available.
-- set connection of all sites togit
mode
-- apply upstream updates
-- reset connection of all sites tosftp
mode
-- clear all caches
Apply WordPress theme and plugin updates:
-- update any plugins that need updating
-- update any themes that need updating
-- commit updates to the environment with a message
-- clear caches in the<site>.<dev>
environment
-- open all<site>.<dev>
environments in browser tabs for review -
Deploy from
<site>.<dev>
to<site>.<test>
:deploy-site-to-test.sh
ordeploy-sites-to-test.sh
-- deploy sites to<site>.<test>
with commit message
-- clear all caches
-- open all<site>.<test>
environments in browser tabs for review -
deploy-to-live.sh
Does exactly the same tha Script 2 does, except deploys from<site>.<test>
to<site>.<live>
.
I use a local script named secrets.sh
placed in the same directory as the scripts. This is where the environment variables are set. To do similar, create a new file in each of the script directories:
touch /my-scripts-location/multiple-sites/secrets.sh
touch /my-scripts-location/single-site/secrets.sh
The PANTHEON_ORG
environment variable used for updating multiple sites. Into your multiple-sites secrets.sh
script, paste the following, using your own ORG UUID
:
#!/bin/bash
# Stash ORG UUID
export PANTHEON_ORG="5234...9de8"
The SITE_NAME
environment variable is used for updating single sites. Into your single-site secrets.sh
script, paste the following, using any portion of your single site's name:
#!/bin/bash
# Stash site name
export SITE_NAME="my-site-name"
sudo chmod +x /my-scripts-location/multiple-sites/secrets.sh
sudo chmod +x /my-scripts-location/single-site/secrets.sh
Once the environment variables are set, the scripts should be run in the order described above.
# note: let each script complete before running the next
user@machine:~$ ./update-sites-to-dev.sh
user@machine:~$ ./deploy-sites-to-test.sh
user@machine:~$ ./deploy-sites-to-live.sh