1
0
Fork 0

docs(deploy): Automatic deployment when doc pushed to master

This commit is contained in:
Pixelastic 2018-11-28 11:36:00 +01:00 committed by Tim Carry
parent 640004f19d
commit b8a1c309e9
6 changed files with 51 additions and 7 deletions

View file

@ -2,4 +2,9 @@ language: node_js
script: "./scripts/test"
branches:
only:
- master
- master
matrix:
include:
- name: "[Documentation] Deploy"
script: "./scripts/travis/deploy"

View file

@ -1,13 +1,7 @@
#!/usr/bin/env sh
set -e
yarn run lint
rm -rf ./dist
yarn run build
# Add the date of last deploy, so the automatic deployment know if it needs to
# override it or not (check ./scripts/netflify-master)
date +%s > ./dist/last_update
gh-pages -d dist

View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Check if the current git repo has changes done in the ./docs folder since last
# push to master
CHANGES_IN_DOCS="$(git diff --name-only master | grep '^docs/')"
if [ "$CHANGES_IN_DOCS" = "" ]; then
exit 1
fi
exit 0

24
scripts/travis/deploy Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Will deploy the documentation website on gh-pages when new commits on master
# Only if it detects changes in ./docs folder
# Note that this will be triggered even for PR targeting master
set -x
if ./scripts/travis/is-pr; then
echo "✘ Documentation is not deployed for pull requests";
exit 0
fi
if ! ./scripts/travis/on-master; then
echo "✘ Documentation is only deployed on the master branch";
exit 0
fi
if ! ./scripts/travis/changes-in-docs-since-master; then
echo "✘ Documentation is not deployed if their are no changes in ./docs";
exit 0
fi
cd ./docs || exit 1
yarn install
yarn run deploy

6
scripts/travis/is-pr Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Check if in a Pull Request
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
exit 0
fi
exit 1

7
scripts/travis/on-master Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Check if on master
if [ "$TRAVIS_BRANCH" = "master" ]; then
exit 0
fi
exit 1