-
-
Save shomanishikawa/9b6c5376cf6db754e6ee to your computer and use it in GitHub Desktop.
Git Repo Update
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 | |
# View Delimiter | |
DLM='-------------------------------------' | |
# Set Output Colors | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
blue=`tput setaf 4` | |
cyan=`tput setaf 6` | |
# Set config'd colors | |
color=${cyan} | |
error=${red} | |
reset=`tput sgr0` | |
# Touch Update File | |
# used to help determine if files are new/updated | |
last='/tmp/.last_pu' | |
touch $last | |
clear | |
echo "${green}Updating from UPSTREAM${reset}" | |
# Check Out Dev Branch | |
echo $DLM | |
echo "${color}Checkout Dev Branch${reset}" | |
git checkout dev | |
if [ $? -ne 0 ]; then | |
echo "${error}Error checking out dev branch${reset}" | |
exit 1 | |
fi | |
# Fetch Upstream | |
echo $DLM | |
echo ${color}Fetch Upstream${reset} | |
git fetch upstream | |
if [ $? -ne 0 ]; then | |
echo "${error}Error getting upstream data${reset}" | |
exit 1 | |
fi | |
# Merge Update Stream Dev to Local Dev | |
echo $DLM | |
echo ${color}Merge Upstream Dev${reset} | |
git merge upstream/dev | |
if [ $? -ne 0 ]; then | |
echo "${error}Error merging upstream dev branch to local${reset}" | |
exit 1 | |
fi | |
# NPM Install any new packages | |
if [ -f package.json ] && [ package.json -nt $last ]; then | |
echo $DLM | |
echo ${color}NPM Install${reset} | |
npm install --silent | |
if [ $? -ne 0 ]; then | |
echo "${error}Error installing NPM modules${reset}" | |
exit 1 | |
fi | |
fi | |
# Bower install any new components | |
if [ -f bower.json ] && [ bower.json -nt $last ]; then | |
echo $DLM | |
echo ${color}Bower Install${reset} | |
bower install -q | |
if [ $? -ne 0 ]; then | |
echo "${error}Error installing Bower components${reset}" | |
exit 1 | |
fi | |
fi | |
# Composer install any new components | |
if [ -f composer.json ] && [ composer.json -nt $last ]; then | |
echo $DLM | |
echo ${color}Composer Install${reset} | |
composer install -q | |
if [ $? -ne 0 ]; then | |
echo "${error}Error installing Composer packages${reset}" | |
exit 1 | |
fi | |
fi | |
# Push local dev to origin dev | |
echo $DLM | |
echo ${color}Push to Origin Dev${reset} | |
git push | |
if [ $? -ne 0 ]; then | |
echo "${error}Error pushing dev branch to Github${reset}" | |
exit 1 | |
fi | |
# Show branches | |
echo $DLM | |
echo ${color}Branches${reset} | |
git branch | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment