How can I combine two post-receive hooks? The first one is a git-slack integration and runs with the following loop:
while read line
do
set -- $line
notify $*
RET=$?
done
and the second one is for my deployment and looks like this:
while read oldrev newrev refname line
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" = "$branch" ]; then
# some deployment commands
elif [ "development" = "$branch" ]; then
# some other deployment commands
fi
done
No matter what branch I use for git, I would like to be able to send notifications to slack.
Any tips on how to combine both loops?
This has not been tested but should work:
while read oldrev newrev refname line
do
set -- "$oldrev $newrev $refname $line"
notify $*
# Not sure the return value is needed since it isn't being used anywhere
RET=$?
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" = "$branch" ]; then
# some deployment commands
elif [ "development" = "$branch" ]; then
# some other deployment commands
fi
done
Hope this helps