From f602bec1405df8b86c1f9329d94dabc26f0ae032 Mon Sep 17 00:00:00 2001 From: liutianyou Date: Thu, 30 May 2024 21:56:02 +0800 Subject: [PATCH] [improve] add filename check in home ci (#2049) Co-authored-by: tomsun28 --- .github/workflows/doc-build-test.yml | 80 ++++++++++++++++++- home/docs/community/document.md | 4 +- .../current/community/document.md | 4 +- 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/.github/workflows/doc-build-test.yml b/.github/workflows/doc-build-test.yml index cd73a461f3f..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] + branches: [ master, dev ] paths: - 'home/**' pull_request: - branches: [ master, dev] + branches: [ master, dev ] 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 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`