I wanted to be able to use Sculpin to generate GitHub pages. Here's what I did...
-
Created a super awesome Sculpin site from the Sculpin Blog Skeleton
-
Make sure everything is under version control in my
master
branch (except things that shouldn't be. see the.gitignore
) -
Updated
publish.sh
:#!/bin/bash if [ $# -ne 1 ]; then echo "usage: ./publish.sh \"commit message\"" exit 1; fi sculpin generate --env=prod git stash git checkout gh-pages cp -R output_prod/* . rm -rf output_* git add * git commit -m "$1" git push origin --all git checkout master git stash pop
-
Now, when I need to publish, I simply run
./publish.sh "commit message"
.
publish.sh
will:
- generate the site using
sculpin generate
- Stash the changes to
master
, if any - Checkout the
gh-pages
branch - Move the generated site to the root of the project
git add -A
to add all the filesgit commit -m "$1"
which includes whatever commit message you passed to./publish.sh
git push origin --all
to push changes to bothmaster
andgh-pages
to GitHub- Checkout
master
, and pop the stash to get any stashed changes to master back
It works pretty fantastically. You can checkout my sample project to see how it works.
The process described above works for project sites, because project sites use a gh-pages
branch for the website. Organization and user pages, however, use the master
branch for the site of a repository named [organization].github.io.
In the case of my sample project, I actually use a branch called drafts
to do the Sculpin work, which then "publishes" the changes to master
, so that the website actually renders correctly.
The publish.sh
looks like this:
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: ./publish.sh \"commit message\""
exit 1;
fi
sculpin generate --env=prod
git stash
git checkout master
cp -R output_prod/* .
rm -rf output_*
git add *
git commit -m "$1"
git push origin --all
git checkout drafts
git stash pop
Slightly different, same concept.
Thanks to @beausimensen for the --env=prod
suggestion.