-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (34 loc) · 1.36 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Check Kebab Case for Markdown Files in PR Commits
on:
pull_request: # Trigger on PR events
paths:
- '**/*.md' # Trigger only when .md files are changed
jobs:
kebab-case-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get list of changed Markdown files
id: changed-files
run: |
# Get the list of added or modified .md files in the PR
git diff --name-only --diff-filter=AM origin/main | grep '\.md$' > changed_files.txt || true
if [ ! -s changed_files.txt ]; then
echo "No Markdown files to check."
exit 0
fi
- name: Check filenames for kebab case
run: |
# Find all .md files excluding node_modules, README.md, and CONTRIBUTING.md, and check filenames for kebab case
invalid_files=$(find . -type f -name '*.md' \
-not -path "./node_modules/*" \
-not -name "README.md" \
-not -name "CONTRIBUTING.md" \
-exec basename {} \; | grep -vE '^[a-z0-9]+(-[a-z0-9]+)*\.md$')
if [ -n "$invalid_files" ]; then
echo "The following Markdown filenames are not in kebab case:"
echo "$invalid_files"
else
echo "All Markdown filenames are in kebab case."
fi