Skip to content

Commit 884f157

Browse files
committed
feat: Add branch protection workflow for main branch validation
- Add GitHub Actions workflow to validate branch protection rules - Check commit message format compliance - Validate file permissions for shell scripts - Check for large files and potential secrets - Ensure proper branch protection enforcement
1 parent 341228f commit 884f157

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Branch Protection Check
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
branch-protection-check:
11+
name: Branch Protection Validation
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Validate commit messages
21+
run: |
22+
if [ "${{ github.event_name }}" = "push" ]; then
23+
echo "Checking commit messages..."
24+
git log --oneline -1 | grep -E "^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\(.+\))?: .{1,50}" || {
25+
echo "❌ Commit message doesn't follow conventional format"
26+
echo "Expected format: type(scope): description"
27+
echo "Types: feat, fix, docs, style, refactor, test, chore, ci, build, perf, revert"
28+
exit 1
29+
}
30+
echo "✅ Commit message format is valid"
31+
fi
32+
33+
- name: Check for secrets
34+
run: |
35+
echo "Checking for potential secrets..."
36+
if command -v detect-secrets &> /dev/null; then
37+
detect-secrets scan --baseline .secrets.baseline
38+
else
39+
echo "⚠️ detect-secrets not available, skipping secret check"
40+
fi
41+
42+
- name: Validate file permissions
43+
run: |
44+
echo "Checking file permissions..."
45+
find . -name "*.sh" -not -perm -111 | while read file; do
46+
echo "❌ Shell script $file is not executable"
47+
exit 1
48+
done
49+
echo "✅ All shell scripts have proper permissions"
50+
51+
- name: Check for large files
52+
run: |
53+
echo "Checking for large files..."
54+
find . -type f -size +10M -not -path "./.git/*" | while read file; do
55+
echo "❌ Large file detected: $file"
56+
echo "Consider using Git LFS for files larger than 10MB"
57+
exit 1
58+
done
59+
echo "✅ No large files detected"

0 commit comments

Comments
 (0)