Created
April 8, 2013 01:49
-
-
Save Traz/5333597 to your computer and use it in GitHub Desktop.
A small working dirty script for use a git branch for a static site in Github pages, generated locally by a Jekyll server in an another git branch. Look at http://traz.github.io/posts/Jekyll-github/
This file contains 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 | |
echo "------- Transfer statics pages to Github (make sure jekyll build ok, and git branch dev commited) ---" | |
current_branch=$(git branch | grep '*' | cut -c 3-) | |
echo -e "-- \033[1;33mGit\033[0m : Current branch :\033[0;31m $current_branch\033[0m" | |
if [ $current_branch != "dev" ]; then | |
echo -e "-- \033[0;31mERROR : Branch must be dev \033[0m" | |
echo "------- Finished" | |
exit 0; | |
fi | |
echo -e "-- \033[0;32mJekyll\033[0m : Build" | |
jekyll build | |
echo -e "-- \033[0;33mGit\033[0m : add ." | |
git add . | |
echo -e "-- \033[0;34mUSER\033[0m : enter the commit message for dev branch : " | |
read dev_commit_message | |
echo -e "-- \033[0;33mGit\033[0m : commit dev " | |
git commit -m "$dev_commit_message" | |
master_commit_id=$(cat .git/refs/heads/master) | |
echo -e "-- \033[0;33mGit\033[0m : get the last COMMIT_ID of master branch :\033[0;31m ${master_commit_id:0:7}\033[0m" | |
commit_tree_id=$(git commit-tree dev^{tree}:_site -p $master_commit_id -m '$dev_commit_message') | |
echo -e "-- \033[0;33mGit\033[0m : commit-tree _site, id :\033[0;31m ${commit_tree_id:0:7} \033[0m" | |
new_master_commit_id=$(git update-ref refs/heads/master $commit_tree_id) | |
echo -e "-- \033[0;33mGit\033[0m : update-ref, new master id : \033[0;31m ${new_master_commit_id:0:7} \033[0m" | |
echo -e "-- \033[0;33mGit\033[0m : checkout master" | |
git checkout master | |
echo -e "-- \033[0;33mGit\033[0m : push origin master to github" | |
git push origin master | |
echo -e "-- \033[0;33mGit\033[0m : checkout dev" | |
git checkout dev | |
echo "------- Finished " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment