Skip to content

Instantly share code, notes, and snippets.

@wibed
Created August 18, 2020 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wibed/f22c5d8cec2e12c77d797eae453b59e5 to your computer and use it in GitHub Desktop.
Save wibed/f22c5d8cec2e12c77d797eae453b59e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Description:
# sync with git remote and rebuild
# docker image if files have been modified
# VARS
_SCRIPTPATH="$(cd "$(dirname $0)"; pwd -P)"
_HEADPATH="${_SCRIPTPATH}/.git/refs/heads/master"
_MODDATE="$(stat -c %Y ${_HEADPATH})"
# main
main(){
while true; do
sleep 5
git pull
[ "$(stat -c %Y ${_HEADPATH})" -gt "${_MODDATE}" ] \
&& _MODDATE=$(stat -c %Y ${_HEADPATH})" \
&& docker-compose stop \
&& docker-compose build \
&& docker-compose up -d
done
}
main
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment