fix release website (#1819)

This commit is contained in:
yangsoon
2021-06-19 14:01:01 +08:00
committed by GitHub
parent e217e9e0df
commit 61d7aff01c
6 changed files with 34 additions and 10 deletions

View File

@@ -18,7 +18,7 @@ jobs:
with:
python-version: '3.7'
- name: Clean md files
run: python ./hack/website/clean-md.py ./docs/en
run: python ./hack/website/format.py markdown ./docs/en
- name: Test Build
env:
VERSION: ${{ github.ref }}

View File

@@ -18,7 +18,7 @@ jobs:
with:
python-version: '3.7'
- name: Clean md files
run: python ./hack/website/clean-md.py ./docs/en
run: python ./hack/website/format.py markdown ./docs/en
- name: Sync to kubevela.io Repo
env:
SSH_DEPLOY_KEY: ${{ secrets.GH_PAGES_DEPLOY }}

View File

@@ -132,7 +132,7 @@ jobs:
with:
python-version: "3.7"
- name: Clean md files
run: python ./hack/website/clean-md.py ./docs/en
run: python ./hack/website/format.py markdown ./docs/en
- name: Sync release to kubevela.io Repo
env:
SSH_DEPLOY_KEY: ${{ secrets.GH_PAGES_DEPLOY }}

View File

@@ -1,6 +1,8 @@
import re
import os
import ast
import sys
import json
def convert_link(md):
@@ -22,16 +24,34 @@ def convert_link(md):
f.write(data)
def main(path):
def format_markdown(path):
files = os.walk(path)
for path, dir_list,file_list in files:
for path, dir_list, file_list in files:
for file_name in file_list:
file_path = os.path.join(path, file_name)
if file_path[-3:] == ".md" or file_path[-4:] == ".mdx":
convert_link(file_path)
def format_json(file):
data = ""
with open(file, "r") as f:
content = f.read()
data = ast.literal_eval(re.sub(r"(\w+)=", r"'\1':", content))
print(f"format versions.json: {data}")
with open(file, "w") as f:
f.write(json.dumps(data))
if __name__ == "__main__":
if len(sys.argv) != 2:
if len(sys.argv) != 3:
sys.exit(1)
main(sys.argv[1])
fmt_type = sys.argv[1]
path = sys.argv[2]
if fmt_type == "markdown":
format_markdown(path)
if fmt_type == "json":
format_json(path)

View File

@@ -18,13 +18,13 @@
set -e
checkDocusaurus(){
if [ --d $1 ]; then
echo "generate docs failed"
if [ ! -d $1 ]; then
echo "generate docs failed"
exit 1;
else
count=`ls $1 | wc -w`
if [ "$count" > "0" ]; then
echo "generate docs failed"
echo "generate docs success"
fi
fi
}

View File

@@ -66,6 +66,8 @@ then
rm versions.json.bak
fi
python ../hack/website/format.py json versions.json
yarn add nodejieba
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
@@ -98,6 +100,8 @@ then
rm versions.json.bak
fi
python ../hack/website/format.py json versions.json
yarn add nodejieba
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile