Using Git Hooks to Trigger Deployments

To generate a nice log of our deployments we use * a local git repository on our production server * with a Git hook.

The hook is located in .git/hooks/post-commit and pretty straight forward:

#!/bin/bash

docker login --username=${REGISTRY_USER} --password=${REGISTRY_PWD} registry.datenkollektiv.de

docker-compose pull
docker-compose up --no-deps -d

Note: You can trigger the hook without doing local noop changes with git commit --allow-empty:

$ git commit --allow-empty -m "Trigger Deployment"