Updated folder/files names to match convention #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify Naming Convention | |
on: | |
pull_request_target: | |
paths: | |
- "pages/**/*" # Trigger the workflow on any file or folder change within the pages directory in a pull request | |
jobs: | |
verifyNaming: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Verify names | |
run: | | |
# Get a list of all files and folders changed in the pull request | |
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
# Filter the list to include only items within the pages directory | |
pages_changed=$(echo "$changed_files" | grep '^pages/') | |
# Initialize an array to store incorrect items | |
incorrect_items=() | |
# Iterate through the files and folders and check their names | |
for item in $pages_changed; do | |
# Check if the item is a file or a folder and does not start with an underscore | |
if [[ (-f $item || -d $item) && $item != pages/**/_* ]]; then | |
# Get the base name of the file or folder (without extension) | |
base_name=$(basename "$item") | |
# Check if the base name is in camel case | |
if ! [[ $base_name =~ ^[a-z]+([A-Z][a-z0-9]+)*$ ]]; then | |
incorrect_items+=("$item") | |
fi | |
fi | |
done | |
# Check if there are any incorrect items | |
if [[ ${#incorrect_items[@]} -gt 0 ]]; then | |
# Output the list of incorrect items | |
echo "The following items have invalid names (camel case required):" | |
for item in "${incorrect_items[@]}"; do | |
echo "- $item" | |
done | |
exit 1 | |
else | |
echo "All items in the pages directory have valid names." | |
fi |