Created
November 29, 2011 22:41
-
-
Save tmtk75/1406939 to your computer and use it in GitHub Desktop.
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/sh | |
## | |
## Publish onto Github Pages, providing an easy way to publish. | |
## | |
## Prepare: creating gh-pages branch at local and remote. | |
## $ jekyll | |
## $ git co -b gh-pages | |
## $ git ls-files | xargs git rm | |
## $ mv _site/* . | |
## $ git add . | |
## $ git ci -m - | |
## $ git push <remote> gh-pages:gh-pages | |
## | |
username=tmtk75 | |
gh_pages=gh-pages | |
repository_name=`git remote -v | grep github.com:$username | sed "s#^.*$username/##" | awk '{print $1}' | uniq` | |
[email protected]:$username/${repository_name} | |
cat<<EOF | |
-------------------------------------------------------------------------------- | |
Publish Github Pages for $repository_name@$username | |
Guessed repository name: $repository_name | |
Repository URL: $repository_url | |
EOF | |
exit | |
echo "-------- Generating with Jekyll" | |
jekyll --base-url=/$repository_name | |
echo "-------- Cloning" | |
tmpdir=`mktemp -u $TMPDIR/tmp.XXXXXX` | |
git clone -b $gh_pages . $tmpdir | |
( cd $tmpdir | |
echo "-------- Synchronizing" | |
git pull $repository_url $gh_pages:gh-pages) | |
cp -r _site/* $tmpdir | |
( cd $tmpdir | |
git add . | |
git ci -am - | |
echo "-------- Pushing" | |
git push $repository_url $gh_pages:gh-pages) | |
rm -rf $tmpdir | |
echo "-------- Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment