Skip to content

Commit

Permalink
[improve] add filename check in home ci (#2049)
Browse files Browse the repository at this point in the history
Co-authored-by: tomsun28 <[email protected]>
  • Loading branch information
LiuTianyou and tomsun28 authored May 30, 2024
1 parent 4442383 commit f602bec
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 6 deletions.
80 changes: 78 additions & 2 deletions .github/workflows/doc-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions home/docs/community/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ git clone [email protected]:<your-github-user-name>/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`

Expand Down

0 comments on commit f602bec

Please sign in to comment.