www.bundesbrandschatzamt.de
Babblings about Systems Administration.

No production change on Friday rule and git

As a sysadmin you probably know the rule: No production changes on Friday! If you use git to manage your automation and happen to not using git tags to finally send your code life this little code snippet might be for you:

#!/bin/sh
if ((`date +"%w"` >= 5)); then
    echo "----------------------------"
    echo "Don't push Friday to Sunday!"
    echo "You can git push --no-verify if you know what you do."
    echo "----------------------------"
    exit 1
fi

Just save it in your git repository as .git/hooks/pre-push and you are good to go.