Last active
August 29, 2015 14:20
-
-
Save sailxjx/62274d0a43ccf7c72d6b to your computer and use it in GitHub Desktop.
Deploy your application automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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