Skip to content

Commit f602bec

Browse files
LiuTianyoutomsun28
andauthored
[improve] add filename check in home ci (#2049)
Co-authored-by: tomsun28 <tomsun28@outlook.com>
1 parent 4442383 commit f602bec

3 files changed

Lines changed: 82 additions & 6 deletions

File tree

.github/workflows/doc-build-test.yml

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ name: DOC CI
1919

2020
on:
2121
push:
22-
branches: [ master, dev]
22+
branches: [ master, dev ]
2323
paths:
2424
- 'home/**'
2525
pull_request:
26-
branches: [ master, dev]
26+
branches: [ master, dev ]
2727
paths:
2828
- 'home/**'
2929

@@ -34,6 +34,82 @@ jobs:
3434
- uses: actions/checkout@v3
3535
with:
3636
fetch-depth: 0
37+
- name: Check filename in home/blog
38+
run: |
39+
TARGET_DIR="./home/blog"
40+
invalid_files=()
41+
while IFS= read -r -d '' file; do
42+
filename=$(basename "$file")
43+
if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then
44+
invalid_files+=("$file")
45+
fi
46+
done < <(find "$TARGET_DIR" -type f -print0)
47+
if [ ${#invalid_files[@]} -ne 0 ]; then
48+
echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)"
49+
for invalid_file in "${invalid_files[@]}"; do
50+
echo "$invalid_file"
51+
done
52+
exit 1
53+
else
54+
echo "All file names are valid."
55+
fi
56+
- name: Check filename in home/docs
57+
run: |
58+
TARGET_DIR="./home/docs"
59+
invalid_files=()
60+
while IFS= read -r -d '' file; do
61+
filename=$(basename "$file")
62+
if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then
63+
invalid_files+=("$file")
64+
fi
65+
done < <(find "$TARGET_DIR" -type f -print0)
66+
if [ ${#invalid_files[@]} -ne 0 ]; then
67+
echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)"
68+
for invalid_file in "${invalid_files[@]}"; do
69+
echo "$invalid_file"
70+
done
71+
exit 1
72+
else
73+
echo "All file names are valid."
74+
fi
75+
- name: Check filename in /zh-cn/docusaurus-plugin-content-blog
76+
run: |
77+
TARGET_DIR="./home/i18n/zh-cn/docusaurus-plugin-content-blog"
78+
invalid_files=()
79+
while IFS= read -r -d '' file; do
80+
filename=$(basename "$file")
81+
if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then
82+
invalid_files+=("$file")
83+
fi
84+
done < <(find "$TARGET_DIR" -type f -print0)
85+
if [ ${#invalid_files[@]} -ne 0 ]; then
86+
echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)"
87+
for invalid_file in "${invalid_files[@]}"; do
88+
echo "$invalid_file"
89+
done
90+
exit 1
91+
else
92+
echo "All file names are valid."
93+
fi
94+
- name: Check filename in /home/i18n/zh-cn/docusaurus-plugin-content-docs/current
95+
run: |
96+
TARGET_DIR="./home/i18n/zh-cn/docusaurus-plugin-content-docs/current"
97+
invalid_files=()
98+
while IFS= read -r -d '' file; do
99+
filename=$(basename "$file")
100+
if [[ ! "$filename" =~ ^[_a-z0-9-]+(\.[_a-z0-9-]+)*$ ]]; then
101+
invalid_files+=("$file")
102+
fi
103+
done < <(find "$TARGET_DIR" -type f -print0)
104+
if [ ${#invalid_files[@]} -ne 0 ]; then
105+
echo "Error: The following files have invalid names:(File name should only contain lowercase letters, numbers, and hyphens.)"
106+
for invalid_file in "${invalid_files[@]}"; do
107+
echo "$invalid_file"
108+
done
109+
exit 1
110+
else
111+
echo "All file names are valid."
112+
fi
37113
- name: NPM INSTALL
38114
working-directory: home
39115
run: npm install

home/docs/community/document.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ This website is compiled using node, using Docusaurus framework components
7878

7979
### Naming convention of files
8080

81-
All lowercase, separated by a dash
81+
Consist entirely of lowercase letters, numbers, underscores, and dashes.
8282

83-
Positive example: `render-dom.js / signup.css / index.html / company-logo.png`
83+
Positive example: `render-dom.js / signup.css / index.html / company-logo.png / hertz_beat.md`
8484

8585
Counter example: `renderDom.js / UserManagement.html`
8686

home/i18n/zh-cn/docusaurus-plugin-content-docs/current/community/document.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ git clone git@github.com:<your-github-user-name>/hertzbeat.git
7878

7979
### 文件的命名规范
8080

81-
全部小写,由破折号分隔
81+
全部由小写,数字,下划线和破折号组成
8282

83-
正例:`render-dom.js / signup.css / index.html / company-logo.png`
83+
正例:`render-dom.js / signup.css / index.html / company-logo.png / hertz_beat.md`
8484

8585
反例:`renderDom.js / UserManagement.html`
8686

0 commit comments

Comments
 (0)