-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FABN-1386: Publish API documentation in Azure
Signed-off-by: Mark S. Lewis <[email protected]> Change-Id: Ib4bbfb2ba5c62263685726bdbfdf3b66ac9db82c
- Loading branch information
1 parent
316a174
commit 9a38da6
Showing
2 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,18 +23,22 @@ steps: | |
softhsm2-util --init-token --slot 0 --label "My token 1" --pin 98765432 --so-pin 98765432 | ||
displayName: 'Install and configure SoftHSM' | ||
|
||
- script: | | ||
npm install | ||
- script: npm install | ||
displayName: 'npm install' | ||
|
||
- script: | | ||
npm run retrieve-images | ||
- script: npm run retrieve-images | ||
displayName: 'Pull Docker images' | ||
|
||
- script: | | ||
npx gulp install-and-generate-certs | ||
- script: npx gulp install-and-generate-certs | ||
displayName: 'Generate credentials' | ||
|
||
- script: | | ||
npx gulp run-test-all | ||
- script: npx gulp run-test-all | ||
displayName: 'Run tests' | ||
|
||
# - script: scripts/ci_scripts/azurePublishApiDocs.sh | ||
# displayName: 'Publish API documentation' | ||
# env: | ||
# GITHUB_USER: 'fabric-sdk-node' | ||
# GITHUB_EMAIL: '[email protected]' | ||
# GITHUB_PASSWORD: $(GITHUB_PASSWORD) | ||
# PUBLISH_REPOSITORY: 'fabric-sdk-node/fabric-sdk-node' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash -e | ||
# | ||
# Copyright IBM Corp All Rights Reserved | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
clonePublishRepository() { | ||
rm -rf "${PUBLISH_DIR}" | ||
git clone "${REPOSITORY_URL}" | ||
} | ||
|
||
buildDocs() { | ||
rm -rf "${BUILD_DIR}" | ||
npx gulp docs | ||
cleanPublishDirectory | ||
cp -r "${BUILD_DIR}"/* "${PUBLISH_DIR}" | ||
} | ||
|
||
cleanPublishDirectory() { | ||
# Root files should only be removed from the top-level publish directory if building the master branch | ||
# removePublishRootFiles | ||
removePublishDirectories | ||
} | ||
|
||
removePublishRootFiles() { | ||
find "${PUBLISH_DIR}" -type f -maxdepth 1 -depth 1 -print | while read -r file; do | ||
echo "Removing ${file}" | ||
rm -f "${file}" | ||
done | ||
} | ||
|
||
removePublishDirectories() { | ||
find "${BUILD_DIR}" -type d -maxdepth 1 -depth 1 -print | while read -r subdir; do | ||
sourceDir=$(basename "${subdir}") | ||
targetDir="${PUBLISH_DIR}/${sourceDir}" | ||
echo "Removing ${targetDir}" | ||
rm -rf "${targetDir}" | ||
done | ||
} | ||
|
||
publishDocs() { | ||
git config --local user.name "${GITHUB_USER}" | ||
git config --local user.email "${GITHUB_EMAIL}" | ||
|
||
git add . | ||
git commit -m "Commit ${COMMIT_HASH}" | ||
git remote add publish "${PUBLISH_URL}" | ||
git push publish master | ||
} | ||
|
||
# Must be run from the repository root directory. | ||
|
||
# Input environment variables: | ||
: "${GITHUB_USER:?}" # The GitHub user name for publishing | ||
: "${GITHUB_EMAIL:?}" # Email address of the GitHub user | ||
: "${GITHUB_PASSWORD:?}" # Password or token for GitHub user | ||
: "${PUBLISH_REPOSITORY:?}" # Qualified GitHub publish repository name (i.e. "organization/repository") | ||
|
||
COMMIT_HASH=$(git rev-parse HEAD) | ||
REPOSITORY_URL="https://github.com/${PUBLISH_REPOSITORY}.git" | ||
PUBLISH_URL="https://${GITHUB_USER}:${GITHUB_PASSWORD}@github.com/${PUBLISH_REPOSITORY}.git" | ||
BUILD_DIR="docs/gen" | ||
PUBLISH_DIR=$(basename "${PUBLISH_REPOSITORY}") | ||
|
||
clonePublishRepository | ||
buildDocs | ||
(cd "${PUBLISH_DIR}" && publishDocs) |