Skip to content

Commit

Permalink
Docusaurus config needs to be updated before building docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Apr 30, 2020
1 parent 4cb0b80 commit 9d2c25b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
script:
- gulp build
- gulp test --coverage
- ./scripts/docs-config.sh
- npm run docs
- npm run typedoc
- gulp package
Expand Down
3 changes: 2 additions & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ set -e
TARGET_DIR='gh-pages'
TARGET_BRANCH='master'
TARGET_REPO_URL="https://$GITHUB_AUTH_TOKEN@github.com/chartjs/chartjs.github.io.git"
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'

# Note: this code also exists in docs-config.sh
# Make sure that this script is executed only for the release and master branches
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
# Travis executes this script from the repository root, so at the same level than package.json
VERSION=$(node -p -e "require('./package.json').version")
Expand Down
32 changes: 32 additions & 0 deletions scripts/docs-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# Note: this code also exists in deploy.sh
# Make sure that this script is executed only for the release and master branches
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
# Travis executes this script from the repository root, so at the same level than package.json
VERSION=$(node -p -e "require('./package.json').version")
elif [ "$TRAVIS_BRANCH" == "master" ]; then
VERSION="master"
else
echo "Skipping deploy because this is not the master or release branch"
exit 0
fi

# tag is next|latest|master
# https://www.chartjs.org/docs/$tag/
function update_config {
local tag=''
if [ "$VERSION" == "master" ]; then
tag=master
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
tag=lastest
else
tag=next
fi
sed -i -e "s/VERSION/$tag/g" "docs/docusaurus.config.js"
}

update_config

0 comments on commit 9d2c25b

Please sign in to comment.