Skip to content

Commit 37f4046

Browse files
authored
Create documentation-review.yml
1 parent 42ac466 commit 37f4046

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Strapi Documentation Style Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- 'docusaurus/docs/**/*.md'
8+
- 'docusaurus/docs/**/*.mdx'
9+
10+
jobs:
11+
validate-documentation:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
cache: 'npm'
22+
cache-dependency-path: 'docusaurus/package-lock.json'
23+
24+
- name: Install dependencies
25+
run: |
26+
cd docusaurus
27+
npm ci
28+
29+
- name: Run Strapi 12 Rules validation
30+
id: validation
31+
run: |
32+
cd docusaurus
33+
node scripts/style-validation/validate-content-style.js --verbose
34+
continue-on-error: true
35+
36+
- name: Comment PR with results
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const fs = require('fs');
41+
const path = require('path');
42+
43+
try {
44+
// Read validation results
45+
const resultsPath = 'docusaurus/style-check-results.json';
46+
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
47+
48+
// Generate comment
49+
let comment = '## 🎯 Strapi Documentation Style Review\n\n';
50+
comment += `*Based on Strapi's 12 Rules of Technical Writing*\n\n`;
51+
52+
// Summary
53+
comment += '### 📊 Summary\n';
54+
comment += `- **Files checked:** ${results.summary.filesProcessed}\n`;
55+
comment += `- **Total issues:** ${results.summary.totalIssues}\n`;
56+
comment += `- **Critical errors:** ${results.issues.errors.length} 🚨\n`;
57+
comment += `- **Warnings:** ${results.issues.warnings.length} ⚠️\n`;
58+
comment += `- **Suggestions:** ${results.issues.suggestions.length} 💡\n\n`;
59+
60+
if (results.summary.totalIssues === 0) {
61+
comment += '🎉 **Perfect!** Your documentation follows all 12 rules of technical writing.\n\n';
62+
} else {
63+
// Show critical errors
64+
if (results.issues.errors.length > 0) {
65+
comment += '### 🚨 Critical Issues (must fix)\n\n';
66+
results.issues.errors.slice(0, 5).forEach(error => {
67+
const fileName = error.file.replace(/^.*\/docs\//, 'docs/');
68+
comment += `**${fileName}:${error.line}**\n`;
69+
comment += `- ${error.message}\n`;
70+
if (error.suggestion) {
71+
comment += `- 💡 *${error.suggestion}*\n`;
72+
}
73+
comment += '\n';
74+
});
75+
76+
if (results.issues.errors.length > 5) {
77+
comment += `*... and ${results.issues.errors.length - 5} more critical issues*\n\n`;
78+
}
79+
}
80+
81+
// Show some warnings
82+
if (results.issues.warnings.length > 0) {
83+
comment += '### ⚠️ Warnings (should address)\n\n';
84+
results.issues.warnings.slice(0, 3).forEach(warning => {
85+
const fileName = warning.file.replace(/^.*\/docs\//, 'docs/');
86+
comment += `**${fileName}:${warning.line}** - ${warning.message}\n`;
87+
});
88+
89+
if (results.issues.warnings.length > 3) {
90+
comment += `\n*... and ${results.issues.warnings.length - 3} more warnings*\n`;
91+
}
92+
comment += '\n';
93+
}
94+
95+
// Show some suggestions
96+
if (results.issues.suggestions.length > 0) {
97+
comment += '### 💡 Suggestions (improvements)\n\n';
98+
results.issues.suggestions.slice(0, 2).forEach(suggestion => {
99+
const fileName = suggestion.file.replace(/^.*\/docs\//, 'docs/');
100+
comment += `**${fileName}:${suggestion.line}** - ${suggestion.message}\n`;
101+
});
102+
103+
if (results.issues.suggestions.length > 2) {
104+
comment += `\n*... and ${results.issues.suggestions.length - 2} more suggestions*\n`;
105+
}
106+
comment += '\n';
107+
}
108+
}
109+
110+
// Add footer
111+
comment += '---\n';
112+
comment += '*🤖 Automated review based on [Strapi\'s 12 Rules of Technical Writing](https://strapi.notion.site/12-Rules-of-Technical-Writing)*\n';
113+
114+
// Post comment
115+
await github.rest.issues.createComment({
116+
issue_number: context.issue.number,
117+
owner: context.repo.owner,
118+
repo: context.repo.repo,
119+
body: comment
120+
});
121+
122+
// Set step output for potential failure
123+
if (results.issues.errors.length > 0) {
124+
core.setFailed(`Found ${results.issues.errors.length} critical errors that must be fixed.`);
125+
}
126+
127+
} catch (error) {
128+
console.error('Error processing results:', error);
129+
130+
await github.rest.issues.createComment({
131+
issue_number: context.issue.number,
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
body: '## ❌ Documentation Style Review Failed\n\n' +
135+
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
136+
`Error: ${error.message}`
137+
});
138+
}

0 commit comments

Comments
 (0)