Skip to content

static-file-name-checker #6

static-file-name-checker

static-file-name-checker #6

Workflow file for this run

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 | 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")
parent_folder=$(basename "$dir")
if [ "$parent_folder" = "." ]; then
parent_folder="root"
fi
combined_info="$parent_folder/$base" # Treat folder name as part of the file name
echo -e "${Yellow} $x. $combined_info${Reset}"
x=$((x + 1))
done