For the past decade or so, I’ve added a group of scripts to every project I’ve worked on. These scripts started out relatively simple and automate some very common tasks. Scroll to the end for some updates.
Why Automate?
Automation encodes the team’s decisions in committed code, reducing questions
(such as “do we like to do git pull --rebase
or just git pull
?”)
and reducing problems caused when people forget to perform a step (such as running tests before pushing code).
How To Automate
Because Bash is ubiquitous, I typically write the scripts in Bash.
Sometimes I write them in a more powerful language if they are complex.
I personally put them in the bin/dev
directory
(I’ll often have a bin/prod
directory for performing production actions,
like bin/prod/
or bin/prod/logs
).
Update
The update
script is run when the developer wants to get the latest code onto their computer.
It typically:
- pulls code from the git remote
- updates dependencies
- runs migrations
- runs doctor
#!/usr/bin/env bash
set -e
CYAN='