-
-
Notifications
You must be signed in to change notification settings - Fork 92
40 lines (36 loc) · 1.12 KB
/
enforce_dir_structure.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
name: Enforce Directory Structure
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
enforce_dir_structure:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate Directory Structure
run: |
echo "Validating directory structure..."
for dir in Boundaries/*; do
if [ -d "$dir" ]; then
id=$(basename "$dir")
json_files=("$dir"/*.json)
if [ ${#json_files[@]} -eq 0 ]; then
echo "::error file=$dir::No JSON files found in directory $dir"
exit 1
fi
for json_file in "${json_files[@]}"; do
if [[ ! "$json_file" =~ ^$dir/[^/]+\.json$ ]]; then
echo "::error file=$json_file::Invalid JSON file name or location: $json_file"
exit 1
fi
done
else
echo "::error file=$dir::Invalid directory: $dir"
exit 1
fi
done
echo "Directory structure is valid."