@@ -20,6 +20,7 @@ name: doc update check
2020#
2121# ## TODO
2222#
23+ # * [ ] to refactor repeated jobs as a matrix job? as separate workflow
2324# * [ ] should make an adapted version that runs on schedule and analyzes all markdown.
2425# * [ ] in this case, instead of commenting pull requests, it should raise issues.
2526# * [ ] should be able to retrieve config files and dictionary from the called ref, not master.
@@ -33,8 +34,7 @@ permissions:
3334 contents : read
3435
3536env :
36- artifacts_dir : artifacts
37- markdown_comment-title : Markdown linter
37+ markdown_comment_title : Markdown linter
3838 markdown_config : ' .github/.markdownlint.yml'
3939 markdown_artifact : markdown_comment.txt
4040
@@ -139,19 +139,95 @@ jobs:
139139 echo "::error::markdown linter encountered an error"
140140 exit 1
141141
142+ markdown-spelling :
143+ needs : markdown-changed
144+ if : ${{ needs.markdown-changed.outputs.proceed == 'true' }}
145+ runs-on : ubuntu-latest
146+ env :
147+ spellcheckreport : ' ./spellcheck-report.txt'
148+ outputs :
149+ proceed : ${{ steps.report-exists.outputs.proceed }}
150+ congrats : ${{ steps.congrats.output.proceed }}
151+ report : ${{ steps.report-exists.outputs.report }}
152+ steps :
153+ - uses : actions/checkout@v5
154+
155+ - name : Checkout spellcheck config
156+ uses : actions/checkout@v5
157+ with :
158+ repository : go-openapi/ci-workflows
159+ ref : master # TODO: retrieve workflow ref
160+ sparse-checkout : |
161+ ${{ env.spellcheck_config }}
162+ ${{ env.spellcheck_dict }}
163+ sparse-checkout-cone-mode : false
164+ path : ci-tools
165+
166+ - name : Copy spellcheck config
167+ # TODO: merge with local if present
168+ run : |
169+ cp ci-tools/${{ env.spellcheck_config }} ${{ env.spellcheck_config }}
170+ cp ci-tools/${{ env.spellcheck_dict }} ${{ env.spellcheck_dict }}
171+
172+ - name : Spellcheck
173+ uses : rojopolis/spellcheck-github-actions@0.51.0
174+ continue-on-error : true
175+ id : spellcheck
176+ with :
177+ config_path : ${{ env.spellcheck_config }}
178+ source_files : ' ${{ needs.markdown-changed.outputs.all_changed_files }}'
179+ task_name : markdown
180+ output_file : ${{ env.spellcheckreport }}
181+
182+ - name : Comment on success
183+ if : ${{ steps.spellcheck.outcome == 'success' }}
184+ id : congrats
185+ run : |
186+ echo "::notice:: no spelling issue with changed markdown"
187+ echo "proceed=true" >> $GITHUB_OUTPUT
188+
189+ echo "### Your changes to markdown docs show impeccable spelling. 👍" >> $GITHUB_STEP_SUMMARY
190+ echo "" >> $GITHUB_STEP_SUMMARY
191+ echo "> ℹ️ INFO: we use [rojopolis/spellcheck-github-actions](https://github.com/rojopolis/spellcheck-github-actions)" >> $GITHUB_STEP_SUMMARY
192+
193+ - name : Comment on spellcheck complaining
194+ if : ${{ steps.spellcheck.outcome != 'success' && hashFiles(env.spellcheckreport) != '' }}
195+ id : report-exists
196+ run : |
197+ echo 'report<<EOF' >> $GITHUB_OUTPUT
198+ cat ${{ env.spellcheckreport }}|sed -e '$a\' >> $GITHUB_OUTPUT
199+ echo 'EOF' >> $GITHUB_OUTPUT
200+
201+ if [[ "$(cat ${{ env.spellcheckreport }}|wc -l)" != "0" ]] ; then
202+ echo "proceed=true" >> $GITHUB_OUTPUT
203+ echo "::notice::Detected some spelling issues with changed markdown"
204+ cat ${{ env.lintreport }}|sed -e '$a\'
205+ else
206+ echo "proceed=false" >> $GITHUB_OUTPUT
207+ echo "::notice::No spelling issues with changed markdown"
208+ fi
209+
210+ - name : Other linter errors
211+ if : ${{ steps.spellcheck.outcome != 'success' && hashFiles(env.spellcheckreport) == '' }}
212+ run : |
213+ echo "::error::spellcheck encountered an error"
214+ exit 1
215+
142216 pr-markdown-congrats :
143217 needs : markdown-lint
144218 if : ${{ needs.markdown-lint.outputs.congrats == 'true' }}
145219 runs-on : ubuntu-latest
146220 outputs :
147- run_id : ${{ github.event.workflow_run.id }}
148- target_repo : ${{ github.repository }}
149- pr_number : ${{ github.event.pull_request.number }}
150- pr_sha : ${{ github.event.pull_request.head.sha }}
151- artifact_name : ${{ env.markdown_artifact }}
152- comment_title : ${{ env.markdown_comment_title }}
221+ run_id : ${{ steps.notify_markdown_congrats.run_id }}
222+ target_repo : ${{ steps.notify_markdown_congrats.target_repo }}
223+ pr_number : ${{ steps.notify_markdown_congrats.pr_number }}
224+ pr_sha : ${{ steps.notify_markdown_congrats.pr_sha }}
225+ artifact_name : ${{ steps.notify_markdown_congrats.artifact_name }}
226+ comment_title : ${{ steps.notify_markdown_congrats.comment_title }}
227+ reaction : ${{ steps.notify_markdown_congrats.reaction }}
153228 steps :
154229 - name : Congrats
230+ id : notify_markdown_congrats
155231 run : |
156232 mkdir -p "${{ env.artifacts_dir }}"
157233 read -d '' MSG<<EOF
@@ -166,6 +242,14 @@ jobs:
166242 echo "" >> $GITHUB_STEP_SUMMARY
167243 echo "> ℹ️ INFO: we use [avtodev/markdown-lint action](https://github.com/avto-dev/markdown-lint)" >> $GITHUB_STEP_SUMMARY
168244
245+ echo "run_id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
246+ echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
247+ echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
248+ echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
249+ echo "artifact_name=${{ env.markdown_artifact }}" >> "$GITHUB_OUTPUT"
250+ echo "comment_title=${{ env.markdown_comment_title }}" >> "$GITHUB_OUTPUT"
251+ echo "reaction=hooray" >> "$GITHUB_OUTPUT"
252+
169253 - name : Upload comment as artifact
170254 uses : actions/upload-artifact@v4
171255 with :
@@ -184,18 +268,19 @@ jobs:
184268 pr_sha : ${{ needs.pr-markdown-congrats.outputs.pr_sha }}
185269 artifact_name : ${{ needs.pr-markdown-congrats.outputs.artifact_name }}
186270 comment_title : ${{ needs.pr-markdown-congrats.outputs.comment_title }}
187- reactions : hooray
271+ reaction : ${{ needs.pr-markdown-congrats.outputs.reaction }}
188272
189273 pr-markdown-report :
190274 needs : markdown-lint
191275 if : ${{ needs.markdown-lint.outputs.proceed == 'true' }}
192276 outputs :
193- run_id : ${{ github.event.workflow_run.id }}
194- target_repo : ${{ github.repository }}
195- pr_number : ${{ github.event.pull_request.number }}
196- pr_sha : ${{ github.event.pull_request.head.sha }}
197- artifact_name : ${{ env.markdown_artifact }}
198- comment_title : ${{ env.markdown_comment_title }}
277+ run_id : ${{ steps.notify_markdown_report.run_id }}
278+ target_repo : ${{ steps.notify_markdown_report.target_repo }}
279+ pr_number : ${{ steps.notify_markdown_report.pr_number }}
280+ pr_sha : ${{ steps.notify_markdown_report.pr_sha }}
281+ artifact_name : ${{ steps.notify_markdown_report.artifact_name }}
282+ comment_title : ${{ steps.notify_markdown_report.comment_title }}
283+ reaction : ${{ steps.notify_markdown_report.reaction }}
199284 runs-on : ubuntu-latest
200285 steps :
201286 - name : Format PR comment
@@ -237,10 +322,19 @@ jobs:
237322 name : ${{ env.markdown_artifact }}
238323
239324 - name : Notify
325+ id : notify_markdown_report
240326 run : |
241327 echo "::notice::Commented pull request ${{ github.event.pull_request.number }}"
242328 echo "::debug::${{ steps.comment_formatter.outputs.updated-text }}"
243329
330+ echo "run_id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
331+ echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
332+ echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
333+ echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
334+ echo "artifact_name=${{ env.markdown_artifact }}" >> "$GITHUB_OUTPUT"
335+ echo "comment_title=${{ env.markdown_comment_title }}" >> "$GITHUB_OUTPUT"
336+ echo "reaction=confused" >> "$GITHUB_OUTPUT"
337+
244338 pr-comment-markdown-report :
245339 name : Create or update comment with report
246340 needs : pr-markdown-report
@@ -253,95 +347,23 @@ jobs:
253347 pr_sha : ${{ needs.pr-markdown-report.outputs.pr_sha }}
254348 artifact_name : ${{ needs.pr-markdown-report.outputs.artifact_name }}
255349 comment_title : ${{ needs.pr-markdown-report.outputs.comment_title }}
256- reactions : confused
257-
258- markdown-spelling :
259- needs : markdown-changed
260- if : ${{ needs.markdown-changed.outputs.proceed == 'true' }}
261- runs-on : ubuntu-latest
262- env :
263- spellcheckreport : ' ./spellcheck-report.txt'
264- outputs :
265- proceed : ${{ steps.report-exists.outputs.proceed }}
266- congrats : ${{ steps.congrats.output.proceed }}
267- report : ${{ steps.report-exists.outputs.report }}
268- steps :
269- - uses : actions/checkout@v5
270-
271- - name : Checkout spellcheck config
272- uses : actions/checkout@v5
273- with :
274- repository : go-openapi/ci-workflows
275- ref : master # TODO: retrieve workflow ref
276- sparse-checkout : |
277- ${{ env.spellcheck_config }}
278- ${{ env.spellcheck_dict }}
279- sparse-checkout-cone-mode : false
280- path : ci-tools
281-
282- - name : Copy spellcheck config
283- # TODO: merge with local if present
284- run : |
285- cp ci-tools/${{ env.spellcheck_config }} ${{ env.spellcheck_config }}
286- cp ci-tools/${{ env.spellcheck_dict }} ${{ env.spellcheck_dict }}
287-
288- - name : Spellcheck
289- uses : rojopolis/spellcheck-github-actions@0.51.0
290- continue-on-error : true
291- id : spellcheck
292- with :
293- config_path : ${{ env.spellcheck_config }}
294- source_files : ' ${{ needs.markdown-changed.outputs.all_changed_files }}'
295- task_name : markdown
296- output_file : ${{ env.spellcheckreport }}
297-
298- - name : Comment on success
299- if : ${{ steps.spellcheck.outcome == 'success' }}
300- id : congrats
301- run : |
302- echo "::notice:: no spelling issue with changed markdown"
303- echo "proceed=true" >> $GITHUB_OUTPUT
304-
305- echo "### Your changes to markdown docs show impeccable spelling. 👍" >> $GITHUB_STEP_SUMMARY
306- echo "" >> $GITHUB_STEP_SUMMARY
307- echo "> ℹ️ INFO: we use [rojopolis/spellcheck-github-actions](https://github.com/rojopolis/spellcheck-github-actions)" >> $GITHUB_STEP_SUMMARY
308-
309- - name : Comment on spellcheck complaining
310- if : ${{ steps.spellcheck.outcome != 'success' && hashFiles(env.spellcheckreport) != '' }}
311- id : report-exists
312- run : |
313- echo 'report<<EOF' >> $GITHUB_OUTPUT
314- cat ${{ env.spellcheckreport }}|sed -e '$a\' >> $GITHUB_OUTPUT
315- echo 'EOF' >> $GITHUB_OUTPUT
316-
317- if [[ "$(cat ${{ env.spellcheckreport }}|wc -l)" != "0" ]] ; then
318- echo "proceed=true" >> $GITHUB_OUTPUT
319- echo "::notice::Detected some spelling issues with changed markdown"
320- cat ${{ env.lintreport }}|sed -e '$a\'
321- else
322- echo "proceed=false" >> $GITHUB_OUTPUT
323- echo "::notice::No spelling issues with changed markdown"
324- fi
325-
326- - name : Other linter errors
327- if : ${{ steps.spellcheck.outcome != 'success' && hashFiles(env.spellcheckreport) == '' }}
328- run : |
329- echo "::error::spellcheck encountered an error"
330- exit 1
350+ reaction : ${{ needs.pr-markdown-report.outputs.reaction }}
331351
332352 pr-markdown-spelling-congrats :
333353 needs : markdown-spelling
334354 if : ${{ needs.markdown-spelling.outputs.congrats == 'true' }}
335355 outputs :
336- run_id : ${{ github.event.workflow_run.id }}
337- target_repo : ${{ github.repository }}
338- pr_number : ${{ github.event.pull_request.number }}
339- pr_sha : ${{ github.event.pull_request.head.sha }}
340- artifact_name : ${{ env.spelling_artifact }}
341- comment_title : ${{ env.spelling_comment_title }}
356+ run_id : ${{ steps.notify_spelling_congrats.run_id }}
357+ target_repo : ${{ steps.notify_spelling_congrats.target_repo }}
358+ pr_number : ${{ steps.notify_spelling_congrats.pr_number }}
359+ pr_sha : ${{ steps.notify_spelling_congrats.pr_sha }}
360+ artifact_name : ${{ steps.notify_spelling_congrats.artifact_name }}
361+ comment_title : ${{ steps.notify_spelling_congrats.comment_title }}
362+ reaction : ${{ steps.notify_spelling_congrats.reaction }}
342363 runs-on : ubuntu-latest
343364 steps :
344365 - name : Congrats
366+ id : notify_spelling_congrats
345367 run : |
346368 mkdir -p artifacts
347369 read -d '' MSG<<EOF
@@ -352,6 +374,14 @@ jobs:
352374
353375 echo "${MSG}" > "${{ env.artifacts_dir }}/${{ env.spellcheck_artifact }}"
354376
377+ echo "run_id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
378+ echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
379+ echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
380+ echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
381+ echo "artifact_name=${{ env.spelling_artifact }}" >> "$GITHUB_OUTPUT"
382+ echo "comment_title=${{ env.spelling_comment_title }}" >> "$GITHUB_OUTPUT"
383+ echo "reaction=hooray" >> "$GITHUB_OUTPUT"
384+
355385 - name : Upload comment as artifact
356386 uses : actions/upload-artifact@v4
357387 with :
@@ -370,18 +400,19 @@ jobs:
370400 pr_sha : ${{ needs.pr-markdown-spelling-congrats.outputs.pr_sha }}
371401 artifact_name : ${{ needs.pr-markdown-spelling-congrats.outputs.artifact_name }}
372402 comment_title : ${{ needs.pr-markdown-spelling-congrats.outputs.comment_title }}
373- reactions : hooray
403+ reaction : ${{ needs.pr-markdown-spelling-congrats.outputs.reaction }}
374404
375405 pr-markdown-spelling-report :
376406 needs : markdown-spelling
377407 if : ${{ needs.markdown-spelling.outputs.proceed == 'true' }}
378408 outputs :
379- run_id : ${{ github.event.workflow_run.id }}
380- target_repo : ${{ github.repository }}
381- pr_number : ${{ github.event.pull_request.number }}
382- pr_sha : ${{ github.event.pull_request.head.sha }}
383- artifact_name : ${{ env.spelling_artifact }}
384- comment_title : ${{ env.spelling_comment_title }}
409+ run_id : ${{ steps.notify_spelling_report.run_id }}
410+ target_repo : ${{ steps.notify_spelling_report.target_repo }}
411+ pr_number : ${{ steps.notify_spelling_report.pr_number }}
412+ pr_sha : ${{ steps.notify_spelling_report.pr_sha }}
413+ artifact_name : ${{ steps.notify_spelling_report.artifact_name }}
414+ comment_title : ${{ steps.notify_spelling_report.comment_title }}
415+ reaction : ${{ steps.notify_spelling_report.reaction }}
385416 runs-on : ubuntu-latest
386417 steps :
387418 - name : Format PR comment
@@ -406,6 +437,7 @@ jobs:
406437 - name : Slap on the wrist
407438 env :
408439 OUTPUT : " ${{ steps.comment_formatter.outputs.updated-text }}"
440+ id : notify_spelling_repo
409441 run : |
410442 mkdir -p "${{ env.artifacts_dir }}"
411443 printenv OUTPUT > "${{ env.artifacts_dir}}/${{ env.spellcheck_artifact }}"
@@ -424,10 +456,19 @@ jobs:
424456 name : ${{ env.spellcheck_artifact }}
425457
426458 - name : Notify
459+ id : spelling_report_notify
427460 run : |
428461 echo "::notice::Commented pull request ${{ github.event.pull_request.number }}"
429462 echo "::debug::${{ steps.comment_formatter.outputs.updated-text }}"
430463
464+ echo "run_id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
465+ echo "target_repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
466+ echo "pr_number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
467+ echo "pr_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
468+ echo "artifact_name=${{ env.spelling_artifact }}" >> "$GITHUB_OUTPUT"
469+ echo "comment_title=${{ env.spelling_comment_title }}" >> "$GITHUB_OUTPUT"
470+ echo "reaction=confused" >> "$GITHUB_OUTPUT"
471+
431472 pr-comment-spelling-report :
432473 name : Create or update comment
433474 needs : pr-markdown-spelling-report
@@ -440,4 +481,4 @@ jobs:
440481 pr_sha : ${{ needs.pr-markdown-spelling-report.outputs.pr_sha }}
441482 artifact_name : ${{ needs.pr-markdown-spelling-report.outputs.artifact_name }}
442483 comment_title : ${{ needs.pr-markdown-spelling-report.outputs.comment_title }}
443- reactions : confused
484+ reaction : ${{ needs.pr-markdown-spelling-report.outputs.reaction }}
0 commit comments