Skip to content

Commit

Permalink
chore(scripts): add script to deploy documentation to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandemo authored and btford committed Mar 28, 2015
1 parent d8e4dee commit 8d2fb77
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
language: node_js

node_js:
- 0.10

env:
global:
- BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready
- LOGS_DIR=/tmp/angular-router-build/logs
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987

- BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready
- LOGS_DIR=/tmp/angular-router-build/logs
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
- secure: cVw9xEN22lkUElPhE41ESL+4D/fVS7uTrYEre8zvH8TlnigaYvfc3SWuMCrsywUJnR86xC4/OClDVxoTCIVWWINJILfs0MJl+/ZhdxJwoqhWC/oenHyPRAK8OGxNhW0dXTbqTaQpiOeuT+d0D244sxPSvXhfziDUg/nPc357dqk=
install:
- mkdir -p $LOGS_DIR
- ./scripts/sauce_connect_setup.sh
- npm install -g npm
- npm install -g gulp karma-cli protractor
- npm install
- ./scripts/wait_for_browser_provider.sh

script:
- ./scripts/test_on_sauce.sh
after_success:
- ./scripts/deploy_docs_to_gh_pages.sh
54 changes: 54 additions & 0 deletions scripts/deploy_docs_to_gh_pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
echo "Starting deployment"
echo "Target: gh-pages branch"

TEMP_DIRECTORY="/tmp/__temp_static_content"
CURRENT_COMMIT=`git rev-parse HEAD`
ORIGIN_URL="https://github.com/angular/router.git"
ORIGIN_URL_WITH_CREDENTIALS=${ORIGIN_URL/\/\/github.com/\/\/$GITHUB_TOKEN@github.com}
COMMIT_MESSAGE=`git log --format=%B --no-merges -n 1`

# Check if commit message contains command to build docs
if echo "$COMMIT_MESSAGE" | grep '\[build-docs\]'
then
echo "Building new documentation"
else
echo "No need to rebuild documentation"
exit 0
fi

mkdir $TEMP_DIRECTORY || exit 1
gulp dgeni || exit 1
cp -r ./dist/docs/* $TEMP_DIRECTORY || exit 1
cp ./docs/*.css $TEMP_DIRECTORY || exit 1
cp .gitignore $TEMP_DIRECTORY || exit 1

echo "Checking out gh-pages branch"
git checkout -B gh-pages || exit 1

echo "Removing old static content"
git rm -rf . || exit 1

echo "Copying newly generated documentation"
ls -al $TEMP_DIRECTORY || exit 1
cp -r $TEMP_DIRECTORY/* . || exit 1
cp $TEMP_DIRECTORY/.gitignore . || exit 1

echo "Configuring git credentials"
git config user.name "Travis-CI" || exit 1
git config user.email "[email protected]" || exit 1

echo "Adding files to git staging area"
git add -A . || exit 1

echo "Creating git commit"
git commit --allow-empty -m "Regenerated documentation for $CURRENT_COMMIT" || exit 1

echo "Pushing new documentation to $ORIGIN_URL"
git push --force --quiet "$ORIGIN_URL_WITH_CREDENTIALS" gh-pages > /dev/null 2>&1

echo "Cleaning up temp files"
rm -Rf $TEMP_DIRECTORY

echo "Deployed successfully."
exit 0

0 comments on commit 8d2fb77

Please sign in to comment.