container/post-receive

29 lines
631 B
Bash
Executable File

#!/bin/sh
#
# This hook updates the working repository on dmeiburg.de
# It is meant to update the docker configs of my servers.
echo "post-receive hook started"
WORK_TREE=~/container
# get changed folders
changed=`GIT_WORK_TREE=$WORK_TREE git diff --dirstat=files,0 HEAD | cut -f3 -d' '`
echo "change apps:"
echo $changed
# update files in working direcotry
GIT_WORK_TREE=~/container git checkout -f
# restart changed docker compose stacks
for app in $changed; do
echo "restarting $app"
cd $WORK_TREE/$changed
# decrypt .env
[ -f .env.asc ] && gpg -d env.asc > .env
docker compose down
docker compose up -d
done
exit