-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (34 loc) · 1.15 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: MarkDown filename validation
on:
pull_request:
paths:
- '**/*.md'
jobs:
kebab-case-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Check filenames for kebab case
run: |
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Reset='\033[0m' # Reset
echo -e "${Blue} Checking all changed Markdown files ..."
changed_files=$(git diff --name-only HEAD^1 HEAD | xargs -n1 basename | grep '\.md$')
if [ -z "$changed_files" ]; then
echo -e "${Green} No changed Markdown files in this PR.${Reset}"
exit 0
fi
x=1
echo -e "${Blue} Changed Markdown files are :.${Reset}"
echo "$changed_files" | while read -r file; do
dir=$(dirname "$file")
base=$(basename "$file")
echo -e "${Yellow} $x. File: $base, Folder: $dir${Reset}"
x=$((x + 1))
done