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