Last active
August 29, 2015 14:12
-
-
Save drautb/33d008c2e08df1fd6b0c to your computer and use it in GitHub Desktop.
Deploys a Frog site to GitHub pages.
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
#!/usr/bin/env sh | |
# This script deploys a Frog site to GitHub pages. | |
# It should be run from the directory containing | |
# the .frogrc file. | |
# | |
# It will determine the output directory from the | |
# .frogrc file, and push it to the gh-pages branch. | |
set -ux | |
FROGRC_FILE=".frogrc" | |
TMP_DIR="/tmp/" | |
GIT_CMD="git" | |
MASTER_BRANCH="master" | |
GH_PAGES_BRANCH="gh-pages" | |
function get_output_dir() { | |
sed -n 's/^output-dir\ =\ \(.*\)$/\1/p' $FROGRC_FILE | |
} | |
function gh-pages_branch_exists() { | |
$GIT_CMD branch | grep -q $GH_PAGES_BRANCH | |
echo $? | |
} | |
raco frog -b | |
output_dir="$(get_output_dir)" | |
cp -R $output_dir $TMP_DIR | |
gh-pages_branch_exists | |
if [ "$(gh-pages_branch_exists)" = "0" ]; then | |
$GIT_CMD checkout $GH_PAGES_BRANCH | |
else | |
$GIT_CMD checkout -b $GH_PAGES_BRANCH | |
fi | |
# Clean out the current directory, put everything in public here. | |
rm -rf * | |
mv $TMP_DIR$output_dir/* . | |
# Commit everything to GitHub pages | |
$GIT_CMD add . | |
$GIT_CMD commit -m "Deploying new site" | |
$GIT_CMD push --set-upstream origin $GH_PAGES_BRANCH | |
# Go back to master, clean out all the generated files | |
$GIT_CMD checkout master | |
$GIT_CMD clean -xf | |
# Cleanup tmp | |
rm -rf $TMP_DIR$output_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment