Skip to content

Commit e1b12fa

Browse files
authored
Fix manual runs (workflow dispatch) implementation of documentation-review.yml
1 parent cea201f commit e1b12fa

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

.github/workflows/documentation-review.yml

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,28 @@ jobs:
6464
if (!fs.existsSync(resultsPath)) {
6565
console.log('No results file found, validation may have failed');
6666
67-
await github.rest.issues.createComment({
68-
issue_number: context.issue.number,
69-
owner: context.repo.owner,
70-
repo: context.repo.repo,
71-
body: '## ❌ Documentation Style Review\n\n' +
72-
'Validation script failed to run. Please check the GitHub Action logs.\n\n' +
73-
'This might be due to missing files or configuration issues.'
74-
});
67+
// Only try to comment if we're in a PR context or manual run with PR number
68+
if (context.eventName === 'pull_request') {
69+
await github.rest.issues.createComment({
70+
issue_number: context.issue.number,
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
body: '## ❌ Documentation Style Review\n\n' +
74+
'Validation script failed to run. Please check the GitHub Action logs.\n\n' +
75+
'This might be due to missing files or configuration issues.'
76+
});
77+
} else if (github.event.inputs?.pr_number) {
78+
await github.rest.issues.createComment({
79+
issue_number: parseInt(github.event.inputs.pr_number),
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
body: '## ❌ Documentation Style Review\n\n' +
83+
'Validation script failed to run. Please check the GitHub Action logs.\n\n' +
84+
'This might be due to missing files or configuration issues.'
85+
});
86+
} else {
87+
console.log('No results file found and no PR to comment on. Manual run completed.');
88+
}
7589
return;
7690
}
7791
@@ -179,12 +193,26 @@ jobs:
179193
} catch (error) {
180194
console.error('Error processing results:', error);
181195
182-
await github.rest.issues.createComment({
183-
issue_number: context.issue.number,
184-
owner: context.repo.owner,
185-
repo: context.repo.repo,
186-
body: '## ❌ Documentation Style Review Failed\n\n' +
187-
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
188-
`Error: ${error.message}`
189-
});
196+
// Only try to comment if we're in a PR context or manual run with PR number
197+
if (context.eventName === 'pull_request') {
198+
await github.rest.issues.createComment({
199+
issue_number: context.issue.number,
200+
owner: context.repo.owner,
201+
repo: context.repo.repo,
202+
body: '## ❌ Documentation Style Review Failed\n\n' +
203+
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
204+
`Error: ${error.message}`
205+
});
206+
} else if (github.event.inputs?.pr_number) {
207+
await github.rest.issues.createComment({
208+
issue_number: parseInt(github.event.inputs.pr_number),
209+
owner: context.repo.owner,
210+
repo: context.repo.repo,
211+
body: '## ❌ Documentation Style Review Failed\n\n' +
212+
'There was an error running the style validation. Please check the GitHub Action logs.\n\n' +
213+
`Error: ${error.message}`
214+
});
215+
} else {
216+
console.log(`Manual validation failed: ${error.message}`);
217+
}
190218
}

0 commit comments

Comments
 (0)