From 201ba0dfd2533a5ace323a6ef35aef5c9eaa9576 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Tue, 22 Dec 2015 16:22:46 -0600 Subject: [PATCH] first attempt at automated docs build. --- .travis.yml | 16 +++++++++---- deploy.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ jsdoc.json | 2 +- package.json | 2 +- 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 deploy.sh diff --git a/.travis.yml b/.travis.yml index f24226c6..6edf9661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,16 @@ sudo: false language: node_js node_js: - - "4.0" - - "0.12" - - "0.10" +- '4.0' +- '0.12' +- '0.10' matrix: - fast_finish: true \ No newline at end of file + fast_finish: true +env: + global: + GH_REPO: github.com/archiverjs/website.git + GH_REPO_BRANCH: master + GH_REPO_DOCSDIR: docs + secure: EKToLBZ66qitO7xrRmytgO0Rm53AVw3IevMtmRVvZ+8tCrwXUmkmGgY5E1aPa3fvtaZPZjtSQGOzSuJ0CR01Ktr70UzkC6YLhbw6IAEwU/AaHmQiHVBoJQTTxgZEk1Mku94M3m8IoZSVky98ShzfLU/cBJfmb3Lb7v4RgJGvTB0= +after_success: +- bash ./deploy.sh \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 00000000..9ce1bb0a --- /dev/null +++ b/deploy.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +echo -n $TRAVIS_REPO_SLUG +echo -n $TRAVIS_NODE_VERSION + +if [ "$TRAVIS_REPO_SLUG" != "archiverjs/node-archiver" ] || [ "$TRAVIS_PULL_REQUEST" == "true" ]; then + exit 0 +fi + +if [ "$TRAVIS_BRANCH" != "master" ] || [ "$TRAVIS_NODE_VERSION" != "4.0" ]; then + exit 0 +fi + +if [ -z "$GH_REPO" ] || [ -z "$GH_SECRET_TOKEN" ]; then + echo "Missing required environment variables to run deploy." + exit 1 +fi + +if [ -z "$GH_USER_EMAIL" ]; then + GH_USER_EMAIL = "travis@travis-ci.org" +fi + +if [ -z "$GH_USER_NAME" ]; then + GH_USER_NAME = "travis-ci" +fi + +if [ -z "$GH_REPO_BRANCH" ]; then + GH_REPO_BRANCH = "master" +fi + +if [ -z "$GH_REPO_DOCSDIR" ]; then + GH_REPO_BRANCH = "docs" +fi + +if [ -z "$GH_REPO_TMPNAME" ]; then + GH_REPO_TMPNAME = "jsdoc-deploy" +fi + +GH_REPO_TMPNAME_STAGED = "${GH_REPO_TMPNAME}-staging" + +echo -e "Running jsdoc...\n" +npm run-script jsdoc +cp -R tmp/jsdoc $HOME/${GH_REPO_TMPNAME_STAGED} + +echo -e "Publishing jsdoc...\n" + +cd $HOME + +git config --global user.email $GH_USER_EMAIL +git config --global user.name $GH_USER_NAME +git clone --quiet --branch=${GH_REPO_BRANCH} https://${GH_SECRET_TOKEN}@${GH_REPO} ${GH_REPO_TMPNAME} > /dev/null + +cd $GH_REPO_TMPNAME +git rm -rf ./$GH_REPO_DOCSDIR +cp -Rf $HOME/$GH_REPO_TMPNAME_STAGED ./$GH_REPO_DOCSDIR +git status +#git add -f . +#git commit -m "deploy: latest jsdoc on successful travis build $TRAVIS_BUILD_NUMBER." +#git push -fq origin $GH_REPO_BRANCH > /dev/null + +#echo -e "Published jsdoc.\n" + diff --git a/jsdoc.json b/jsdoc.json index 48e26675..8e25c8bc 100644 --- a/jsdoc.json +++ b/jsdoc.json @@ -6,7 +6,7 @@ }, "opts": { "recurse": true, - "destination": "../archiver-website/docs/", + "destination": "tmp/jsdoc/", "template": "node_modules/minami" }, "plugins": [ diff --git a/package.json b/package.json index 73602735..fbcc09e8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "scripts": { "test": "mocha --reporter dot", - "gendocs": "jsdoc -c jsdoc.json readme.md", + "jsdoc": "jsdoc -c jsdoc.json readme.md", "bench": "node benchmark/simple/pack-zip.js" }, "dependencies": {