Skip to content

Commit 5ed632f

Browse files
committed
auto doc publishing improvements:
* only run on first job of a given build (instead of publishing the same docs 3 times) * run for both tagged and regular builds * include commit hash that triggered build in gh-pages commit message
1 parent 7cdf0ff commit 5ed632f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

jsdoc/publish.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22

33
# based on http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/
4-
# todo: add && [ "$TRAVIS_TAG" != "" ] after confirming it works otherwise
54

6-
if [ "$TRAVIS_REPO_SLUG" == "watson-developer-cloud/node-sdk" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_TAG" ]; then
5+
# checking the build/job numbers allows it to only publish once even though we test against multiple node.js versions
6+
7+
if [ "$TRAVIS_REPO_SLUG" == "watson-developer-cloud/node-sdk" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ] && [ "$TRAVIS_BUILD_NUMBER.1" == "$TRAVIS_JOB_NUMBER" ]; then
78

89
echo "Publishing JSDoc..."
910

@@ -12,16 +13,21 @@ if [ "$TRAVIS_REPO_SLUG" == "watson-developer-cloud/node-sdk" ] && [ "$TRAVIS_PU
1213
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/node-sdk gh-pages > /dev/null
1314

1415
pushd gh-pages
15-
cp -Rf ../doc/watson-developer-cloud/* ./
16+
# on tagged builds, $TRAVIS_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)
17+
rm -rf $TRAVIS_BRANCH
18+
mkdir $TRAVIS_BRANCH
19+
cp -Rf ../doc/watson-developer-cloud/*/* ./$TRAVIS_BRANCH
1620
git add -f .
17-
git commit -m "JSDdoc for $TRAVIS_TAG"
21+
git commit -m "JSDdoc for $TRAVIS_BRANCH ($TRAVIS_COMMIT)"
1822
git push -fq origin gh-pages > /dev/null
1923
popd
2024

21-
echo -e "Published JSDoc for $TRAVIS_TAG to gh-pages.\n"
25+
# todo: whip up a quick index file that links to all subdirs
26+
27+
echo -e "Published JSDoc for $TRAVIS_BRANCH to gh-pages.\n"
2228

2329
else
2430

25-
echo -e "Not publishing docs for tag $TRAVIS_TAG on branch $TRAVIS_BRANCH of repo $TRAVIS_REPO_SLUG"
31+
echo -e "Not publishing docs for build $TRAVIS_BUILD_NUMBER ($TRAVIS_JOB_NUMBER) on branch $TRAVIS_BRANCH of repo $TRAVIS_REPO_SLUG"
2632

2733
fi

0 commit comments

Comments
 (0)