You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/06/16 02:25:35 UTC

[pulsar-site] branch fix/crowdin-build-update created (now 34d59b97fbd)

This is an automated email from the ASF dual-hosted git repository.

urfree pushed a change to branch fix/crowdin-build-update
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


      at 34d59b97fbd fix: optimize crowdin build flow

This branch includes the following new commits:

     new 34d59b97fbd fix: optimize crowdin build flow

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[pulsar-site] 01/01: fix: optimize crowdin build flow

Posted by ur...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

urfree pushed a commit to branch fix/crowdin-build-update
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit 34d59b97fbdb8e92f05765bb774d5cc33ee7e949
Author: Li Li <ur...@apache.org>
AuthorDate: Thu Jun 16 10:20:37 2022 +0800

    fix: optimize crowdin build flow
    
    Signed-off-by: Li Li <ur...@apache.org>
---
 .github/workflows/ci-pulsar-website-docs-sync.yaml |  4 +++-
 site2/tools/build-site.sh                          | 19 -----------------
 site2/website-next/.gitignore                      |  1 +
 site2/website-next/docusaurus.config.js            | 12 ++++++++---
 site2/website-next/scripts/split-version-build.sh  | 24 +++++++++++++++++-----
 5 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/ci-pulsar-website-docs-sync.yaml b/.github/workflows/ci-pulsar-website-docs-sync.yaml
index 83df47dce43..6147512a2bb 100644
--- a/.github/workflows/ci-pulsar-website-docs-sync.yaml
+++ b/.github/workflows/ci-pulsar-website-docs-sync.yaml
@@ -63,6 +63,8 @@ jobs:
 
           git remote -v
 
-          git diff-index --quiet HEAD || (git commit -m "Docs sync done from apache/pulsar(#$PULSAR_COMMIT_ID)" && git push -q origin main)
+          # git diff-index --quiet HEAD || (git commit -m "Docs sync done from apache/pulsar(#$PULSAR_COMMIT_ID)" && git push -q origin main)
+          git commit --allow-empty -m "Docs sync done from apache/pulsar(#$PULSAR_COMMIT_ID)"
+          git push -q origin main
 
           echo "Docs sync done from apache/pulsar(#$PULSAR_COMMIT_ID)"
diff --git a/site2/tools/build-site.sh b/site2/tools/build-site.sh
index e05fb46b368..016cbd6948e 100755
--- a/site2/tools/build-site.sh
+++ b/site2/tools/build-site.sh
@@ -72,25 +72,6 @@ cd ${ROOT_DIR}/site2/$WEBSITE_DIR
 yarn
 
 if [ -n "$NEXT" ]; then
-  yarn write-translations
-  CURRENT_HOUR=$(date +%H)
-  CURRENT_HOUR=${CURRENT_HOUR#0}
-  echo "------ crowdin envs:" "CROWDIN_UPLOAD: "$CROWDIN_UPLOAD "CROWDIN_DOWNLOAD: "$CROWDIN_DOWNLOAD "CURRENT_HOUR: "$CURRENT_HOUR
-  if [[ "$CROWDIN_UPLOAD" == "1" || $CURRENT_HOUR -eq 0 ]]; then
-    echo "------ exec crowdin upload"
-    yarn run crowdin-upload
-  else
-    echo "------ skip crowdin upload"
-  fi
-  if [[ "$CROWDIN_DOWNLOAD" == "1" || $CURRENT_HOUR -eq 18 ]]; then
-    echo "------ exec crowdin download"
-    yarn crowdin-download
-    echo 'all' >scripts/.language
-  else
-    echo "------ skip crowdin download"
-    echo 'en' >scripts/.language
-  fi
-
   node scripts/replace.js
   node scripts/split-swagger-by-version.js
   # Because there are too many versions of the document, the memory overflows during the full build.
diff --git a/site2/website-next/.gitignore b/site2/website-next/.gitignore
index 5d757981fdd..7a41a65f3b3 100644
--- a/site2/website-next/.gitignore
+++ b/site2/website-next/.gitignore
@@ -17,6 +17,7 @@ build-*/
 .env.production.local
 
 .build-versions.json
+.build-languages.json
 
 npm-debug.log*
 yarn-debug.log*
diff --git a/site2/website-next/docusaurus.config.js b/site2/website-next/docusaurus.config.js
index bc4d48d9115..fbe4f3f1050 100644
--- a/site2/website-next/docusaurus.config.js
+++ b/site2/website-next/docusaurus.config.js
@@ -6,7 +6,7 @@ const linkifyRegex = require("./plugins/remark-linkify-regex");
 const versions = require("./versions.json");
 const versionsMap = {
   ..._.keyBy(
-    versions.slice(1).map(item => {
+    versions.slice(1).map((item) => {
       return {
         label: item,
         path: item,
@@ -21,11 +21,17 @@ const versionsMap = {
 };
 
 let buildVersions = ["current"];
+let buildLanguages = ["en"];
 try {
   buildVersions = require("./.build-versions.json");
 } catch (error) {
   //do nothing
 }
+try {
+  buildLanguages = require("./.build-languages.json");
+} catch (error) {
+  //do nothing
+}
 
 const oldUrl = "https://pulsar.apache.org";
 const url = "https://pulsar.apache.org";
@@ -129,7 +135,7 @@ module.exports = {
   },
   i18n: {
     defaultLocale: "en",
-    locales: ["en", "zh-CN", "zh-TW", "ja", "fr", "ko"],
+    locales: buildLanguages,
     localeConfigs: {
       "zh-CN": {
         label: "简体中文",
@@ -311,7 +317,7 @@ module.exports = {
               label: "Sponsorship",
               href: "https://www.apache.org/foundation/sponsorship",
             },
-	    {
+            {
               label: "Privacy",
               href: "https://www.apache.org/foundation/policies/privacy.html",
             },
diff --git a/site2/website-next/scripts/split-version-build.sh b/site2/website-next/scripts/split-version-build.sh
index 5f468aa8179..93b8b40ea63 100755
--- a/site2/website-next/scripts/split-version-build.sh
+++ b/site2/website-next/scripts/split-version-build.sh
@@ -4,14 +4,14 @@ node scripts/split-version.js
 
 locals=("en" "zh-CN" "zh-TW" "ja" "ko" "fr")
 latest=$(cat scripts/.latest)
-buildLanguage=$(cat scripts/.language)
+BUILD_ALL_LANGUAGE="en"
 buildVersion="next"
 
 echo "changed files: "
 echo $@
 
 function _build() {
-    if [[ "$buildLanguage" == "en" ]]; then
+    if [[ "$BUILD_ALL_LANGUAGE" == "0" ]]; then
         echo "only build en"
         yarn build --locale en
     else
@@ -23,9 +23,11 @@ function _build() {
 function _buildVersion() {
     if [[ $buildVersion = "next" ]]; then
         echo "..." ${buildVersion} "and" $latest" begin build..."
+        echo "[\"en\", \"zh-CN\", \"zh-TW\", \"ja\", \"fr\", \"ko\"]" >./.build-languages.json
         echo "[\"current\", \"${latest}\"]" >.build-versions.json
     else
         echo "..." $buildVersion "begin build..."
+        echo "[\"en\", \"zh-CN\"]" >./.build-languages.json
         echo "[\"${buildVersion}\"]" >.build-versions.json
     fi
 
@@ -48,17 +50,29 @@ function _buildVersion() {
     echo "..." $buildVersion "build done..."
 }
 
+yarn write-translations
 CURRENT_HOUR=$(date +%H)
 CURRENT_HOUR=${CURRENT_HOUR#0}
+#force set CURRENT_HOUR for testing crowdin download and build all
+CURRENT_HOUR=18
+echo "------ crowdin envs:" "CROWDIN_UPLOAD: "$CROWDIN_UPLOAD "CROWDIN_DOWNLOAD: "$CROWDIN_DOWNLOAD "CURRENT_HOUR: "$CURRENT_HOUR
+if [[ $CURRENT_HOUR -eq 0 ]]; then
+    echo "------ exec crowdin upload"
+    yarn run crowdin-upload
+else
+    echo "------ skip crowdin upload"
+fi
 if [[ $CURRENT_HOUR -eq 18 ]]; then
+    echo "------ exec crowdin download"
+    yarn crowdin-download
+    BUILD_ALL_LANGUAGE="1"
     BUILD_ALL_VERSION="1"
 else
+    echo "------ skip crowdin download"
+    BUILD_ALL_LANGUAGE="0"
     BUILD_ALL_VERSION="0"
 fi
 
-# sometimes need build specify versions
-SUPPLEMENT_VERSIONS=$latest
-
 # Build only the versions that has changed
 # Build next version that has any changed
 while read version; do