Skip to content

Commit 30141ff

Browse files
authored
Improve documentation-review.yml messages
1 parent bec5914 commit 30141ff

File tree

1 file changed

+67
-10
lines changed

1 file changed

+67
-10
lines changed

.github/workflows/documentation-review.yml

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version: '18'
21+
cache: 'yarn'
22+
cache-dependency-path: 'docusaurus/yarn.lock'
2123

2224
- name: Install dependencies
2325
run: |
@@ -36,61 +38,116 @@ jobs:
3638
with:
3739
script: |
3840
const fs = require('fs');
41+
const path = require('path');
3942
4043
try {
44+
// Read validation results
4145
const resultsPath = 'docusaurus/style-check-results.json';
4246
4347
if (!fs.existsSync(resultsPath)) {
48+
console.log('No results file found, validation may have failed');
49+
4450
await github.rest.issues.createComment({
4551
issue_number: context.issue.number,
4652
owner: context.repo.owner,
4753
repo: context.repo.repo,
48-
body: '## ❌ Documentation Style Review Failed\n\nValidation script could not run. Check the logs.'
54+
body: '## ❌ Documentation Style Review\n\n' +
55+
'Validation script failed to run. Please check the GitHub Action logs.\n\n' +
56+
'This might be due to missing files or configuration issues.'
4957
});
5058
return;
5159
}
52-
60+
5361
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
5462
63+
// Generate comment
5564
let comment = '## 🎯 Strapi Documentation Style Review\n\n';
56-
comment += `### 📊 Summary\n`;
65+
comment += `*Based on Strapi's 12 Rules of Technical Writing*\n\n`;
66+
67+
// Summary
68+
comment += '### 📊 Summary\n';
5769
comment += `- **Files checked:** ${results.summary.filesProcessed}\n`;
70+
comment += `- **Total issues:** ${results.summary.totalIssues}\n`;
5871
comment += `- **Critical errors:** ${results.issues.errors.length} 🚨\n`;
5972
comment += `- **Warnings:** ${results.issues.warnings.length} ⚠️\n`;
6073
comment += `- **Suggestions:** ${results.issues.suggestions.length} 💡\n\n`;
6174
6275
if (results.summary.totalIssues === 0) {
63-
comment += '🎉 **Perfect!** Your documentation follows all 12 rules.\n\n';
76+
comment += '🎉 **Perfect!** Your documentation follows all 12 rules of technical writing.\n\n';
6477
} else {
78+
// Show critical errors
6579
if (results.issues.errors.length > 0) {
6680
comment += '### 🚨 Critical Issues (must fix)\n\n';
67-
results.issues.errors.forEach(error => {
81+
results.issues.errors.slice(0, 5).forEach(error => {
6882
const fileName = error.file.replace(/^.*\/docs\//, 'docs/');
69-
comment += `**${fileName}:${error.line}** - ${error.message}\n`;
70-
if (error.suggestion) comment += `💡 ${error.suggestion}\n`;
83+
comment += `**${fileName}:${error.line}**\n`;
84+
comment += `- ${error.message}\n`;
85+
if (error.suggestion) {
86+
comment += `- 💡 *${error.suggestion}*\n`;
87+
}
7188
comment += '\n';
7289
});
90+
91+
if (results.issues.errors.length > 5) {
92+
comment += `*... and ${results.issues.errors.length - 5} more critical issues*\n\n`;
93+
}
94+
}
95+
96+
// Show some warnings
97+
if (results.issues.warnings.length > 0) {
98+
comment += '### ⚠️ Warnings (should address)\n\n';
99+
results.issues.warnings.slice(0, 3).forEach(warning => {
100+
const fileName = warning.file.replace(/^.*\/docs\//, 'docs/');
101+
comment += `**${fileName}:${warning.line}** - ${warning.message}\n`;
102+
});
103+
104+
if (results.issues.warnings.length > 3) {
105+
comment += `\n*... and ${results.issues.warnings.length - 3} more warnings*\n`;
106+
}
107+
comment += '\n';
108+
}
109+
110+
// Show some suggestions
111+
if (results.issues.suggestions.length > 0) {
112+
comment += '### 💡 Suggestions (improvements)\n\n';
113+
results.issues.suggestions.slice(0, 2).forEach(suggestion => {
114+
const fileName = suggestion.file.replace(/^.*\/docs\//, 'docs/');
115+
comment += `**${fileName}:${suggestion.line}** - ${suggestion.message}\n`;
116+
});
117+
118+
if (results.issues.suggestions.length > 2) {
119+
comment += `\n*... and ${results.issues.suggestions.length - 2} more suggestions*\n`;
120+
}
121+
comment += '\n';
73122
}
74123
}
75124
76-
comment += '---\n*🤖 Based on Strapi\'s 12 Rules of Technical Writing*';
125+
// Add footer
126+
comment += '---\n';
127+
comment += '*🤖 Automated review based on [Strapi\'s 12 Rules of Technical Writing](https://strapi.notion.site/12-Rules-of-Technical-Writing)*\n';
77128
129+
// Post comment
78130
await github.rest.issues.createComment({
79131
issue_number: context.issue.number,
80132
owner: context.repo.owner,
81133
repo: context.repo.repo,
82134
body: comment
83135
});
84136
137+
// Set step output for potential failure
85138
if (results.issues.errors.length > 0) {
86-
core.setFailed(`Found ${results.issues.errors.length} critical errors.`);
139+
core.setFailed(`Found ${results.issues.errors.length} critical errors that must be fixed.`);
87140
}
88141
89142
} catch (error) {
143+
console.error('Error processing results:', error);
144+
90145
await github.rest.issues.createComment({
91146
issue_number: context.issue.number,
92147
owner: context.repo.owner,
93148
repo: context.repo.repo,
94-
body: `## ❌ Error\n\n${error.message}`
149+
body: '## ❌ Documentation Style Review Failed\n\n' +
150+
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
151+
`Error: ${error.message}`
95152
});
96153
}

0 commit comments

Comments
 (0)