-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (73 loc) · 2.93 KB
/
validate-blog-posts.yml
File metadata and controls
91 lines (73 loc) · 2.93 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Validate Blog Posts
on:
# Run on pushes that modify blog posts or the validation script
push:
paths:
- 'docs/_posts/**'
- 'docs/_config.yml'
- 'tests/test_blog_post_validation.py'
- '.github/workflows/validate-blog-posts.yml'
# Run on pull requests
pull_request:
paths:
- 'docs/_posts/**'
- 'docs/_config.yml'
- 'tests/test_blog_post_validation.py'
- '.github/workflows/validate-blog-posts.yml'
# Allow manual triggering
workflow_dispatch:
jobs:
validate-blog-posts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pyyaml
- name: Run blog post validation tests
run: |
echo "🔍 Running blog post validation tests..."
python -m pytest tests/test_blog_post_validation.py -v -o addopts=""
- name: Run standalone validation check
run: |
echo "🧪 Running standalone validation..."
python tests/test_blog_post_validation.py
- name: Check Jekyll config for dangerous patterns
run: |
echo "⚙️ Checking Jekyll configuration..."
# Ensure template files are excluded
if ! grep -q "post-template.md" docs/_config.yml; then
echo "❌ Jekyll config should exclude post-template.md"
exit 1
fi
if ! grep -q "drafts/" docs/_config.yml; then
echo "❌ Jekyll config should exclude drafts/ directory"
exit 1
fi
echo "✅ Jekyll config validation passed"
- name: Check for dangerous placeholder files
run: |
echo "🚨 Checking for dangerous files..."
# Look for files with YYYY-MM-DD patterns (excluding this workflow and the test)
dangerous_files=$(find docs/ -name "*YYYY-MM-DD*" -type f 2>/dev/null || true)
if [ -n "$dangerous_files" ]; then
echo "❌ Found files with YYYY-MM-DD patterns:"
echo "$dangerous_files"
exit 1
fi
# Look for literal placeholder dates in markdown files (excluding code blocks and comments)
if grep -r "date: YYYY-MM-DD HH:MM:SS" docs/ --include="*.md" | grep -v template | grep -v "# placeholder" | grep -v "\`\`\`yaml"; then
echo "❌ Found literal placeholder dates in published content"
exit 1
fi
echo "✅ No dangerous files found"
- name: Summary
run: |
echo "✅ All blog post validations passed!"
echo "📊 Blog posts are properly formatted and safe for Jekyll processing."