From 0d41f27d4e25d22e73fc9954d134c802aa208fea Mon Sep 17 00:00:00 2001 From: Gary Hansen Date: Wed, 21 Jun 2017 03:54:42 +0000 Subject: [PATCH] initial version --- git.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 git.sh diff --git a/git.sh b/git.sh new file mode 100644 index 0000000..d5e6cfb --- /dev/null +++ b/git.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# +# This shell script is for use with incron file monitoring to deploy from git when triggered to do so via the creation of git.flag +# +# $1 folder where the project lives +# $2 file change that triggered the build. Should only change when git.flag is created in the folder. incron is not capable of watching files that dont yet exist. +# $3 is the branch to deploy +# +if [ "$1" = "" ]; then + echo "git.sh - This shell script is for use with incron file monitoring to deploy from git when triggered to do so" + echo "git.sh " + exit +fi +if [ "$2" = git.flag ]; then +#cd to the folder where the git deployment lives +cd $1 + + if [ -e "git.flag" ]; then + slackecho "Deploying to $1" + #remove flag + rm git.flag + + #git fetch / reset deployment + git fetch --all + git reset --hard origin/$3 + + #fix permissions + chown www-data:www-data $1 -R + slackecho "Completed" + fi + +fi