It's Drupal Security Update Wedesday - you've got a security update that makes a simple change, which you've tested and feel pretty confident you can safely deploy to your servers without much human intervention. But running composer update and getting everything set up is a lot of work.
Here's a script I've written that creates a new branch for your drupal update and pushes the changes to your dev and main branch. Behold "automated_update":
#!/usr/bin/php
<?php
function pause($message) {
print "$message\n";
$stdin = fopen('php://stdin', 'r');
$response = fgetc($stdin);
}
if (empty($argv[1])) {
print "Usage ./automated_update <directory>\n";
die;
}
$directory = rtrim($argv[1],'/');
if (!is_dir($directory)) {
print "$directory is not a directory!\n";
die;
}
$date = date("Ymd-his");
$branch = "feature/$directory-$date/automated_update";
print "Creating $branch\n";
$cmd = shell_exec("
cd $directory &&
git checkout main &&
git pull &&
lando rebuild -y &&
rm -rf vendor &&
lando composer update &&
lando drush updb -y &&
lando drush cex -y &&
git checkout -b $branch &&
git add composer.lock config &&
git status 2>&1
");
echo $cmd;
pause('Hit ENTER to continue...');
$cmd = shell_exec("
cd $directory &&
git commit -m 'Automated Update' &&
git push --set-upstream origin $branch &&
git checkout dev &&
git merge $branch &&
git push &&
git checkout main &&
git merge $branch &&
git push
");
automated_update - a script for bulk updating drupal sites with lando, composer and drush
Note that this is NOT a replacement for proper testing. All this does is create a new branch with all the updates composer update wants to run, and merges the changes to the dev and main branch. It does have a pause so you can see the composer changes before you merge to dev and main - a human sanity check.
Additionally, this script doesn't actually deploy changes to your website. I use Jenkins to manually deploy first to my dev sites, check that they're working as expected, and then deploy to main.
Still, this automated_update script has saved me a lot of time dancing the same moves around lando, composer, and drush for a dozen sites.