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 38a168f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
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
6 changes: 3 additions & 3 deletions 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 Expand Up @@ -35,10 +36,9 @@ function update_with_tag {
move_sample_scripts $tag

deploy_versioned_files $tag

sed -i -e "s/VERSION/$tag/g" "docs/$tag/docusaurus.config.js"
}

# Note: this code also exists in docs-config.sh
# tag is next|latest|master
# https://www.chartjs.org/docs/$tag/
# https://www.chartjs.org/samples/$tag/
Expand Down
33 changes: 33 additions & 0 deletions scripts/docs-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/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 docs configuration because this is not the master or release branch"
exit 0
fi

# Note: this code also exists in deploy.sh
# 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 38a168f

Please sign in to comment.