Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] add filename check in home ci #2049

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading