Skip to content

Commit

Permalink
Configure deployment of docs to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry committed Nov 18, 2018
1 parent 53e1f01 commit 4500924
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -2,6 +2,7 @@

## Build generated
build/
docs/
DerivedData

## Various settings
Expand Down Expand Up @@ -45,6 +46,5 @@ Carthage/Build
## Icon must end with two \r
Icon


## Thumbnails
._*
58 changes: 58 additions & 0 deletions .scripts/update-gh-pages.sh
@@ -0,0 +1,58 @@
#!/bin/bash -e

ORG="tmandry"
NAME="Swindler"
CHECKOUT_PATH="docs/output/gh-pages"
DOC_URL_ROOT="docs"
SITE_URL="https://$ORG.github.io/$NAME"

RELEASE="$1"
SHA=`git rev-parse HEAD`
REPO=`git config remote.origin.url`

RELEASE="$TRAVIS_BRANCH"
PERMALINK="$SHA"
if [ "$TRAVIS_TAG" != "" ]; then
RELEASE="$TRAVIS_TAG"
PERMALINK="$TRAVIS_TAG"
fi

if [ "$RELEASE" == "" ]; then exit 1; fi
if [ "$GITHUB_TOKEN" == "" ]; then exit 2; fi

rm -rf "$CHECKOUT_PATH"
git clone --branch gh-pages "$REPO" "$CHECKOUT_PATH"

TARGET_DIR="$DOC_URL_ROOT/$RELEASE"

echo " ==> Installing jazzy"
gem install jazzy --no-rdoc --no-ri

echo " ==> Generating docs"
jazzy \
--clean \
--output "$CHECKOUT_PATH/$TARGET_DIR" \
--github_file_prefix "https://github.com/$ORG/$NAME/blob/$PERMALINK" \
--root-url "$SITE_URL/$TARGET_DIR"

pushd "$CHECKOUT_PATH"

git config user.name "Deployment Bot"
git config user.email "deploy@travis-ci.org"

CHANGE_SET=$(git status -s)
if [ "$CHANGE_SET" == "" ]; then
echo "No doc changes present; exiting."
exit 0
fi

echo " ==> Deploying docs"
set -x

git add -A "$TARGET_DIR"
git commit -m "[$RELEASE] Regenerate docs"
git push -q "https://$GITHUB_TOKEN@github.com/$ORG/$NAME.git" gh-pages

popd

echo " ==> Docs updated at $SITE_URL/$TARGET_DIR"
8 changes: 8 additions & 0 deletions .travis.yml
Expand Up @@ -6,3 +6,11 @@ xcode_workspace: Swindler.xcworkspace
xcode_scheme: Swindler

script: xcodebuild -workspace Swindler.xcworkspace -scheme Swindler build test

deploy:
- provider: script
script: bash .scripts/update-gh-pages.sh
skip_cleanup: true
on:
all_branches: true
condition: '"$TRAVIS_BRANCH" == "master" || "$TRAVIS_TAG" != ""'

0 comments on commit 4500924

Please sign in to comment.