Drush 8 Exit Code Workaround

A bug in older versions of drush stop errors bubbling up to shell exit codes. This is problematic if you have a shell script with a sequence of commands that depend on the previous one completing successfully. It also makes detecting failed CI builds, deployments and cronjobs near impossible. Unfortunately I’m stuck using drush8 as Lagoon does not support dynamic drush aliases in newer versions. The bash function below will terminate a script with exit-code 1 if the output piped to it includes exception or error....

October 15, 2020

Log in to GitHub Docker registry with just a token

I recently worked on a project to push our private docker images to GitHub’s package registry. Our CI only had a GITHUB_TOKEN environment variable set, but docker login requires a username too. Rather than add a new environment variable to the build and an assumption that the username and token had to match, I used this snippet to derive the username from the token and log in to the registry....

April 27, 2020

Improve your bash scripts with this boilerplate template

First up - here’s the template. Continue reading below for an explanation of each component. Unofficial Strict Mode set -euo pipefail IFS=$'\n\t' There’s a few things going on here - set -e will exit the script if any command returns a non-zero status. set -u will stop a script if using an undefined variable. set -o pipefail will terminate the script at the first failed command in a pipeline....

March 14, 2019