Skip to content

Commit

Permalink
feat: documentation on gh-page
Browse files Browse the repository at this point in the history
  • Loading branch information
paibamboo committed Oct 3, 2019
1 parent 45f2855 commit f1074c7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ node_modules
!.idea/inspectionProfiles/
.awcache/
.jest/cache/

# Storybook
storybook
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ src
.travis.yml
Dockerfile
wallaby.conf.js
storybook
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ after_script: greenkeeper-lockfile-upload

after_success:
- bash <(curl -s https://codecov.io/bash)
- ./doc/documentation.sh

jobs:
include:
Expand Down
20 changes: 20 additions & 0 deletions doc/documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
export NODE_DEBUG=gh-pages
npm i gh-pages
npm run doc:build

if [ -z "$TRAVIS_TAG" ]; then
echo "it's not a tag build, publishing branch document"
npm run doc:publish $TRAVIS_BRANCH
export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
curl -X POST \
https://api.github.com/repos/crazyfactory/shop-webapp-components/issues/$TRAVIS_PULL_REQUEST/comments \
-H "authorization: token $GH_TOKEN" \
-H 'content-type: application/json' \
-d "{
\"body\": \"Hi there, the generated documentation has been made available [gh-pages/$BRANCH](https://crazyfactory.github.io/shop-webapp-components/$BRANCH). Don't forget to delete from [gh-pages/](https://github.com/crazyfactory/shop-webapp-components/tree/gh-pages/) branch once this PR is merged!\"
}"
else
echo "it's a tag, publishing main document"
npm run doc:publish
fi
8 changes: 8 additions & 0 deletions doc/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const ghpages = require('gh-pages');

const args = process.env.npm_config_argv ? JSON.parse(process.env.npm_config_argv).remain : [];
const branch = args.length > 0 ? args[0] : '.';

ghpages.publish('storybook', {
dest: branch
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"lint": "eslint \"src/**/**.ts*\"",
"lint:fix": "npm run lint -s -- --fix",
"doc": "start-storybook -p 6060",
"doc:build": "build-storybook -o storybook",
"prepublish": "npm run clean && npm run build"
},
"author": "Crazy Factory <[email protected]>",
Expand Down

0 comments on commit f1074c7

Please sign in to comment.