Created
January 19, 2019 16:46
-
-
Save cimentadaj/2a790961f1b76fe82cffbf2492be9d60 to your computer and use it in GitHub Desktop.
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
wd=$(ls | grep cimentadaj.github.io) | |
NOCOLOR="\033[1;0m" | |
function error { | |
RED="\033[1;31m" | |
echo -e "${RED}$1${NOCOLOR}" | |
} | |
function message { | |
BLUE="\033[1;34m" | |
echo -e "${BLUE}$1${NOCOLOR}" | |
} | |
cd $wd | |
message "Checking correct branch..." | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$branch" != 'root' ]]; then | |
error "$wd must be in branch root to run this script!"; | |
exit 1; | |
fi | |
message "Git pull and commit in root" | |
git pull | |
git add --ignore-errors --force . | |
git commit -m 'New blog post' | |
git push | |
message "Checkout to master and pull" | |
git checkout master | |
git pull | |
cd .. | |
message "Clone repo to temp_folder and remove old folder" | |
git clone -b root https://github.com/cimentadaj/cimentadaj.github.io.git tempfolder | |
rm -R cimentadaj.github.io/* | |
cd tempfolder | |
message "Copy public folder" | |
cp -R public/. ../cimentadaj.github.io/ | |
cd ../cimentadaj.github.io | |
message "Remove temporary folder" | |
rm -rf ../tempfolder | |
message "Add new changes in master" | |
git add --ignore-errors --force . | |
git commit -m 'New blog post' | |
git push | |
message "Checkout to root" | |
git checkout root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment