Skip to content

Instantly share code, notes, and snippets.

@HugoPoi
Last active December 16, 2015 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HugoPoi/5379565 to your computer and use it in GitHub Desktop.
Save HugoPoi/5379565 to your computer and use it in GitHub Desktop.
Auto-merge script for git repo. You must use auth 'ssh' and a cron task. Then add a tag to your branch with the prefix pattern, the script will auto merge to the last tag version.
#!/bin/sh
#
# Auto-merge script for git repo
# You must use auth 'ssh' and a cron task :-)
# Conf:
REPO_PATH=/home/user/yourgitrepo
TAG_PATTERN=prod*
# Conf End
cd $REPO_PATH
git fetch --tags
lasttag=$(git tag -l $TAG_PATTERN | sort -n | tail -1)
if [ "$lasttag" != "" ] ;
then error=$(git merge $lasttag 2>&1)
if [ "$error" != "Already up-to-date." ] ;
then echo "Auto Merge $REPO_PATH to : $lasttag \n $error" | /usr/bin/mail -s "Auto-Merge" your@email.com
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment