Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FABN-1039: Fix master branch doc publishing #74

Merged
merged 1 commit into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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