1+ name : Documentation Check
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize]
6+ push :
7+ branches :
8+ - main
9+ - master
10+
11+ jobs :
12+ check-documentation :
13+ name : Check Repository Documentation
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v3
19+
20+ - name : Check for required documentation files
21+ id : doc-check
22+ run : |
23+ echo "=== Documentation Check ==="
24+
25+ # Initialize status
26+ status="pass"
27+ missing_files=""
28+
29+ # Check for README
30+ if [ ! -f "README.md" ] && [ ! -f "README" ] && [ ! -f "readme.md" ]; then
31+ echo "❌ Missing: README file"
32+ missing_files="$missing_files README.md"
33+ status="fail"
34+ else
35+ echo "✅ Found: README file"
36+ fi
37+
38+ # Check for LICENSE
39+ if [ ! -f "LICENSE" ] && [ ! -f "LICENSE.md" ] && [ ! -f "LICENSE.txt" ]; then
40+ echo "⚠️ Missing: LICENSE file (recommended)"
41+ missing_files="$missing_files LICENSE"
42+ else
43+ echo "✅ Found: LICENSE file"
44+ fi
45+
46+ # Check for CONTRIBUTING guidelines
47+ if [ ! -f "CONTRIBUTING.md" ] && [ ! -f "contributing.md" ]; then
48+ echo "ℹ️ Missing: CONTRIBUTING.md (optional but recommended)"
49+ else
50+ echo "✅ Found: CONTRIBUTING guidelines"
51+ fi
52+
53+ # Check for Code of Conduct
54+ if [ ! -f "CODE_OF_CONDUCT.md" ] && [ ! -f "code_of_conduct.md" ]; then
55+ echo "ℹ️ Missing: CODE_OF_CONDUCT.md (optional)"
56+ else
57+ echo "✅ Found: Code of Conduct"
58+ fi
59+
60+ # Set outputs
61+ echo "status=$status" >> $GITHUB_OUTPUT
62+ echo "missing_files=$missing_files" >> $GITHUB_OUTPUT
63+
64+ - name : Check README quality
65+ if : success()
66+ run : |
67+ echo "=== README Quality Check ==="
68+
69+ # Find README file
70+ README_FILE=""
71+ for file in README.md README readme.md; do
72+ if [ -f "$file" ]; then
73+ README_FILE="$file"
74+ break
75+ fi
76+ done
77+
78+ if [ -n "$README_FILE" ]; then
79+ # Check README length
80+ lines=$(wc -l < "$README_FILE")
81+ if [ "$lines" -lt 10 ]; then
82+ echo "⚠️ README is very short ($lines lines). Consider adding more detail."
83+ else
84+ echo "✅ README has $lines lines"
85+ fi
86+
87+ # Check for essential sections
88+ essential_sections=(
89+ "## Installation"
90+ "## Usage"
91+ "## Contributing"
92+ "## License"
93+ )
94+
95+ echo ""
96+ echo "Checking for essential sections:"
97+ for section in "${essential_sections[@]}"; do
98+ if grep -q "$section" "$README_FILE"; then
99+ echo "✅ Found: $section"
100+ else
101+ echo "⚠️ Missing: $section"
102+ fi
103+ done
104+ fi
105+
106+ - name : Post PR comment
107+ if : github.event_name == 'pull_request' && steps.doc-check.outputs.status == 'fail'
108+ uses : actions/github-script@v6
109+ with :
110+ github-token : ${{ secrets.GITHUB_TOKEN }}
111+ script : |
112+ const missing = '${{ steps.doc-check.outputs.missing_files }}'.trim().split(' ');
113+ const body = `## 📋 Documentation Check
114+
115+ This repository is missing required documentation:
116+
117+ ${missing.map(file => `- ❌ \`${file}\``).join('\n')}
118+
119+ Please add the missing documentation files before merging this PR.
120+
121+ ### Quick Start
122+
123+ You can use our templates:
124+ - [README Template](https://github.com/${{ github.repository_owner }}/jumpoff/blob/main/templates/README_TEMPLATE.md)
125+ - [LICENSE Chooser](https://github.com/${{ github.repository_owner }}/jumpoff/blob/main/templates/LICENSE_CHOOSER.md)
126+ - [Contributing Template](https://github.com/${{ github.repository_owner }}/jumpoff/blob/main/templates/CONTRIBUTING_TEMPLATE.md)
127+ `;
128+
129+ github.rest.issues.createComment({
130+ issue_number: context.issue.number,
131+ owner: context.repo.owner,
132+ repo: context.repo.repo,
133+ body: body
134+ });
135+
136+ - name : Fail if required docs missing
137+ if : steps.doc-check.outputs.status == 'fail'
138+ run : |
139+ echo "❌ Documentation check failed!"
140+ echo "Missing required files: ${{ steps.doc-check.outputs.missing_files }}"
141+ exit 1
0 commit comments