Skip to content

Commit

Permalink
FABN-1039: Fix master branch doc publishing (#74)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and harrisob committed Dec 14, 2019
1 parent 913ad7c commit 2cb20d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
},
"opts": {
"tutorials": "docs/tutorials",
"destination": "docs/gen/master"
"destination": "docs/gen"
},
"templates": {
"systemName": "Hyperledger Fabric SDK for node.js",
"theme": "cosmo"
}
}
}
37 changes: 18 additions & 19 deletions scripts/ci_scripts/azurePublishApiDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ set -e -o pipefail

readonly COMMIT_HASH=$(git rev-parse HEAD)
readonly BUILD_DIR="${PROJECT_DIR}/docs/gen"
readonly TEMPLATE_DIR="${PROJECT_DIR}/docs/redirectTemplates"
readonly DOCS_BRANCH='gh-pages'
readonly STAGING_RELEASE_DIR="${STAGING_DIR}/${SOURCE_BRANCH}"

prepareStaging() {
echo "Preparing staging directory: ${STAGING_DIR}"
Expand All @@ -39,35 +41,32 @@ _stagingGitSetUp() {
buildDocs() {
echo "Building documentation for ${SOURCE_BRANCH} branch in ${BUILD_DIR}"
rm -rf "${BUILD_DIR}"
BUILD_BRANCH="${SOURCE_BRANCH}" DOCS_ROOT="${BUILD_DIR}" npm run docs
}

copyToStaging() {
echo "Copying built documentation from ${BUILD_DIR} to ${STAGING_DIR}"
rsync -r "${BUILD_DIR}/" "${STAGING_DIR}"
npm run docs
}

cleanStaging() {
local releaseDir targetDir
# Remove release sub-directories that have been re-built
find "${BUILD_DIR}" -type d -maxdepth 1 -mindepth 1 -print | while read -r subdir; do
releaseDir=$(basename "${subdir}")
targetDir="${STAGING_DIR}/${releaseDir}"
echo "Removing ${targetDir}"
rm -rf "${targetDir}"
done
echo "Removing ${STAGING_RELEASE_DIR}"
rm -rf "${STAGING_RELEASE_DIR}"

if [[ ${SOURCE_BRANCH} = master ]]; then
removeStagingRootFiles
fi
}

removeStagingRootFiles() {
local rootFile
find "${STAGING_DIR}" -type f -maxdepth 1 -mindepth 1 -print | while read -r rootFile; do
echo "Removing ${rootFile}"
rm -f "${rootFile}"
done
find "${STAGING_DIR}" -type f -maxdepth 1 -mindepth 1 \
-exec echo Removing {} \; \
-exec rm -f {} \;
}

copyToStaging() {
echo "Copying built documentation from ${BUILD_DIR} to ${STAGING_RELEASE_DIR}"
rsync -r "${BUILD_DIR}/" "${STAGING_RELEASE_DIR}"

if [[ ${SOURCE_BRANCH} = master ]]; then
echo "Copying template files from ${TEMPLATE_DIR} to ${STAGING_DIR}"
rsync -r "${TEMPLATE_DIR}/" "${STAGING_DIR}"
fi
}

publishDocs() {
Expand Down

0 comments on commit 2cb20d4

Please sign in to comment.