forked from angular/router
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(scripts): add script to deploy documentation to gh-pages
- Loading branch information
Showing
2 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
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 |
This file contains 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
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 |