Skip to content

Instantly share code, notes, and snippets.

@sailxjx
Last active August 29, 2015 14:20
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 sailxjx/62274d0a43ccf7c72d6b to your computer and use it in GitHub Desktop.
Save sailxjx/62274d0a43ccf7c72d6b to your computer and use it in GitHub Desktop.
Deploy your application automatically
#!/bin/bash
DIR=$1
if [[ "$DIR" == '' ]] || [[ $DIR == '-h' ]] || [[ $DIR == '--help' ]]; then
cat <<EOF
Usage: dailyga your-repos-directory
Options:
-h, --help output usage information
EOF
exit
fi
# Change directory
cd $DIR
git checkout master && git fetch
HAS_CHANGED=$(git show-ref master | cut -d ' ' -f1 | uniq | wc -l | tr -d '[[:space:]]')
if [[ $HAS_CHANGED == '1' ]]; then
cat <<EOF
Current branch master is up to date.
Nothing to be deploy.
EOF
exit 0
fi
git fetch && git rebase origin/master
if [[ ! $? == 0 ]]; then
>&2 echo "Something wrong during the rebasing process, please check you repository."
exit 2
fi
function mvern() {
[ $1 ] && mversion $1 -m "$1" || mversion
}
DATE=$(date +%Y-%m-%d)
mvern "build-$DATE" && git push && git push --tag && sneaky d ga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment