forked from iamdevdhanush/Devops
-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (27 loc) · 976 Bytes
/
structure-guard.yml
File metadata and controls
36 lines (27 loc) · 976 Bytes
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
name: Enforce Repository Structure
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
structure-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check modified paths
run: |
echo "Checking modified files..."
git fetch origin main
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
INVALID_PATHS=$(echo "$CHANGED_FILES" | grep -Ev \
'^(level-[0-9]+-|challenges/|resources/|roadmap/|\.github/|README.md|CONTRIBUTING.md|CODE_OF_CONDUCT.md|LICENSE)')
if [ -n "$INVALID_PATHS" ]; then
echo "❌ Invalid paths detected:"
echo "$INVALID_PATHS"
echo ""
echo "Contributions must follow the level-based structure."
exit 1
fi
echo "✅ Structure check passed."