From cd467e64571ad01124ef402a59975071f5375abb Mon Sep 17 00:00:00 2001 From: LiuTianyou Date: Wed, 29 May 2024 23:08:42 +0800 Subject: [PATCH 1/3] [improve] add filename check in home ci --- .github/workflows/doc-build-test.yml | 80 +++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build-test.yml b/.github/workflows/doc-build-test.yml index cd73a461f3f..9811f2b4dd9 100644 --- a/.github/workflows/doc-build-test.yml +++ b/.github/workflows/doc-build-test.yml @@ -19,11 +19,11 @@ name: DOC CI on: push: - branches: [ master, dev] + branches: [ master, dev, filename-check-ci ] paths: - 'home/**' pull_request: - branches: [ master, dev] + branches: [ master, dev, filename-check-ci ] paths: - 'home/**' @@ -34,6 +34,82 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Check filename in home/blog + run: | + TARGET_DIR="./home/blog" + invalid_files=() + while IFS= read -r -d '' file; do + filename=$(basename "$file") + if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then + invalid_files+=("$file") + fi + done < <(find "$TARGET_DIR" -type f -print0) + if [ ${#invalid_files[@]} -ne 0 ]; then + echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)" + for invalid_file in "${invalid_files[@]}"; do + echo "$invalid_file" + done + exit 1 + else + echo "All file names are valid." + fi + - name: Check filename in home/docs + run: | + TARGET_DIR="./home/docs" + invalid_files=() + while IFS= read -r -d '' file; do + filename=$(basename "$file") + if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then + invalid_files+=("$file") + fi + done < <(find "$TARGET_DIR" -type f -print0) + if [ ${#invalid_files[@]} -ne 0 ]; then + echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)" + for invalid_file in "${invalid_files[@]}"; do + echo "$invalid_file" + done + exit 1 + else + echo "All file names are valid." + fi + - name: Check filename in /zh-cn/docusaurus-plugin-content-blog + run: | + TARGET_DIR="./home/i18n/zh-cn/docusaurus-plugin-content-blog" + invalid_files=() + while IFS= read -r -d '' file; do + filename=$(basename "$file") + if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then + invalid_files+=("$file") + fi + done < <(find "$TARGET_DIR" -type f -print0) + if [ ${#invalid_files[@]} -ne 0 ]; then + echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)" + for invalid_file in "${invalid_files[@]}"; do + echo "$invalid_file" + done + exit 1 + else + echo "All file names are valid." + fi + - name: Check filename in /home/i18n/zh-cn/docusaurus-plugin-content-docs/current + run: | + TARGET_DIR="./home/i18n/zh-cn/docusaurus-plugin-content-docs/current" + invalid_files=() + while IFS= read -r -d '' file; do + filename=$(basename "$file") + if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then + invalid_files+=("$file") + fi + done < <(find "$TARGET_DIR" -type f -print0) + if [ ${#invalid_files[@]} -ne 0 ]; then + echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)" + for invalid_file in "${invalid_files[@]}"; do + echo "$invalid_file" + done + exit 1 + else + echo "All file names are valid." + fi - name: NPM INSTALL working-directory: home run: npm install From 4fef6a202a26697cff279a84c68236122f6079d5 Mon Sep 17 00:00:00 2001 From: LiuTianyou Date: Wed, 29 May 2024 23:16:24 +0800 Subject: [PATCH 2/3] [doc] update the contribution guidelines --- home/docs/community/document.md | 4 ++-- .../current/community/document.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/home/docs/community/document.md b/home/docs/community/document.md index 5288e257b2f..a4f871bb753 100644 --- a/home/docs/community/document.md +++ b/home/docs/community/document.md @@ -78,9 +78,9 @@ This website is compiled using node, using Docusaurus framework components ### Naming convention of files -All lowercase, separated by a dash +Consist entirely of lowercase letters, numbers, underscores, and dashes. -Positive example: `render-dom.js / signup.css / index.html / company-logo.png` +Positive example: `render-dom.js / signup.css / index.html / company-logo.png / hertz_beat.md` Counter example: `renderDom.js / UserManagement.html` diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/community/document.md b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/community/document.md index 83c376f68fb..e696b3c35e4 100644 --- a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/community/document.md +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/community/document.md @@ -78,9 +78,9 @@ git clone git@github.com:/hertzbeat.git ### 文件的命名规范 -全部小写,由破折号分隔。 +全部由小写,数字,下划线和破折号组成。 -正例:`render-dom.js / signup.css / index.html / company-logo.png` +正例:`render-dom.js / signup.css / index.html / company-logo.png / hertz_beat.md` 反例:`renderDom.js / UserManagement.html` From 4006adf50e36f2e626d75586942b2123d025b9f9 Mon Sep 17 00:00:00 2001 From: LiuTianyou Date: Wed, 29 May 2024 23:18:16 +0800 Subject: [PATCH 3/3] [cleanup] remove branch name used for testing in ci --- .github/workflows/doc-build-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build-test.yml b/.github/workflows/doc-build-test.yml index 9811f2b4dd9..cb67cfaee2d 100644 --- a/.github/workflows/doc-build-test.yml +++ b/.github/workflows/doc-build-test.yml @@ -19,11 +19,11 @@ name: DOC CI on: push: - branches: [ master, dev, filename-check-ci ] + branches: [ master, dev ] paths: - 'home/**' pull_request: - branches: [ master, dev, filename-check-ci ] + branches: [ master, dev ] paths: - 'home/**'