Skip to content

Commit

Permalink
Add review feedback: extract shell function
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Jun 3, 2021
1 parent 3d66e19 commit b34f43f
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions site2/tools/build-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,7 @@
ROOT_DIR=$(git rev-parse --show-toplevel)
VERSION=$(${ROOT_DIR}/src/get-project-version.py)

set -x -e

export NODE_OPTIONS="--max-old-space-size=2048" #increase to 2gb, default is 512mb
${ROOT_DIR}/site2/tools/generate-api-docs.sh
cd ${ROOT_DIR}/site2/website
yarn
yarn write-translations

if [ "$CROWDIN_DOCUSAURUS_API_KEY" != "UNSET" ]; then
# upload only if environment variable CROWDIN_UPLOAD=1 is set
# or current hour is 0-5
# this leads to executing crowdin-upload once per day when website build is scheduled
# to run with cron expression '0 */6 * * *'
CURRENT_HOUR=$(date +%H)
if [[ "$CROWDIN_UPLOAD" == "1" || $CURRENT_HOUR -lt 6 ]]; then
yarn run crowdin-upload
fi
yarn run crowdin-download

function workaround_crowdin_problem_by_copying_files() {
# TODO: remove this after figuring out why crowdin removed code tab when generating translated files
# https://github.com/apache/pulsar/issues/5816
cp versioned_docs/version-2.4.2/functions-develop.md translated_docs/zh-CN/version-2.4.2/functions-develop.md
Expand Down Expand Up @@ -71,6 +53,29 @@ if [ "$CROWDIN_DOCUSAURUS_API_KEY" != "UNSET" ]; then
cp versioned_docs/version-2.5.0/io-overview.md translated_docs/ko/version-2.5.0/io-overview.md
cp versioned_docs/version-2.5.1/functions-develop.md translated_docs/ko/version-2.5.1/functions-develop.md
cp versioned_docs/version-2.5.2/functions-develop.md translated_docs/ko/version-2.5.2/functions-develop.md
}


set -x -e

export NODE_OPTIONS="--max-old-space-size=2048" #increase to 2gb, default is 512mb
${ROOT_DIR}/site2/tools/generate-api-docs.sh
cd ${ROOT_DIR}/site2/website
yarn
yarn write-translations

if [ "$CROWDIN_DOCUSAURUS_API_KEY" != "UNSET" ]; then
# upload only if environment variable CROWDIN_UPLOAD=1 is set
# or current hour is 0-5
# this leads to executing crowdin-upload once per day when website build is scheduled
# to run with cron expression '0 */6 * * *'
CURRENT_HOUR=$(date +%H)
if [[ "$CROWDIN_UPLOAD" == "1" || $CURRENT_HOUR -lt 6 ]]; then
yarn run crowdin-upload
fi
yarn run crowdin-download

workaround_crowdin_problem_by_copying_files
else
# set English as the only language to build in this case
cat > languages.js <<'EOF'
Expand Down

0 comments on commit b34f43f

Please sign in to comment.