Created
November 3, 2015 13:24
-
-
Save fwilhe/d0cb0a954d902c892856 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
#!/bin/sh | |
# based on https://raw.githubusercontent.com/fkling/esprima_ast_explorer/master/scripts/push-site.sh | |
# precondition: `gh-pages` branch does exist | |
TARGETPATH="../$(basename $(pwd))_gh_pages" | |
REMOTE=$(git remote -v | grep origin | grep "(push)" | cut -f 2 | cut -d ' ' -f 1) | |
if ! git diff --quiet && git diff --cached --quiet; then | |
echo >&2 "Cannot build, your index contains uncommitted changes." | |
exit 1 | |
fi | |
if [ ! -d "$TARGETPATH" ]; then | |
echo "Cloning into '$TARGETPATH'..." | |
git clone ./ "$TARGETPATH" | |
cd "$TARGETPATH" | |
git checkout gh-pages | |
git remote set-url --push origin $REMOTE | |
cd - > /dev/null | |
fi | |
echo "Building..." | |
./gradlew asciidoctor | |
echo "Copying artifacts..." | |
cp -R build/asciidoc/html5/* "$TARGETPATH/" | |
# Commit changes | |
cd $TARGETPATH | |
if git diff --quiet && git diff --cached --quite; then | |
echo "No changes, nothing to commit..." | |
exit 0 | |
fi | |
echo "Committing..." | |
git add . | |
git commit -m "Automatic commit by push-site.sh: Update site" | |
echo "Pushing..." | |
git push origin | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment