@@ -115,6 +115,89 @@ jobs:
115115 git commit -m 'Style *mds' || echo "No changes to commit"
116116 git push origin || echo "No changes to commit"
117117
118+ # ############################ Check Markdown Formatting ###################################
119+ markdown-linter :
120+ name : Markdown linter
121+ needs : yaml-check
122+ runs-on : ubuntu-latest
123+ if : ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}}
124+ container :
125+ image : jhudsl/base_ottr:dev
126+
127+ steps :
128+ - name : Checkout files
129+ uses : actions/checkout@v4
130+ with :
131+ token : ${{ secrets.GH_PAT }}
132+
133+ - name : Make the report
134+ run : |
135+ git config --global --add safe.directory $GITHUB_WORKSPACE
136+ git config --global user.name 'github-actions[bot]'
137+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
138+
139+ mkdir -p check_reports
140+
141+ curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \
142+ -o resources/.markdownlint-cli2.jsonc
143+
144+ markdownlint-cli2 "**/*.md" "#node_modules" \
145+ >> check_reports/markdown_lint_report.txt 2>&1
146+ continue-on-error : true
147+
148+ # Commit the markdown report
149+ - name : Commit markdown report to preview branch
150+ id : commit
151+ run : |
152+ branch_name='preview-${{ github.event.pull_request.number }}'
153+ error_num=$(cat check_reports/markdown_lint_report.txt | wc -l)
154+ error_num="$((error_num-12))"
155+ echo "markdown_issues=$error_num" >> $GITHUB_OUTPUT
156+ git add check_reports/markdown_lint_report.txt --force
157+ git commit -m 'Add markdown report' || echo "No report to commit"
158+ git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
159+ git push --force || echo "No report to commit"
160+ shell : bash
161+
162+ - name : Find Comment
163+ uses : peter-evans/find-comment@v2
164+ id : fc
165+ with :
166+ issue-number : ${{ github.event.pull_request.number }}
167+ comment-author : ' github-actions[bot]'
168+ body-includes :
169+
170+ - name : Build components of the comment
171+ id : build-components
172+ run : |
173+ report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/check_reports/markdown_lint_report.txt")
174+ echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
175+ echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
176+ echo ${{steps.commit.outputs.markdown_issues}}
177+
178+ - name : Create or update comment
179+ if : steps.commit.outputs.markdown_issues > 4
180+ uses : peter-evans/create-or-update-comment@v2
181+ with :
182+ comment-id : ${{ steps.fc.outputs.comment-id }}
183+ issue-number : ${{ github.event.pull_request.number }}
184+ body : |
185+ [Markdown linter report here](${{ steps.build-components.outputs.report_link }})
186+ $(error_num) potential errors reported
187+ _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_
188+ edit-mode : replace
189+
190+ - name : Comment if no changes
191+ if : steps.commit.outputs.markdown_issues > 4
192+ uses : peter-evans/create-or-update-comment@v2
193+ with :
194+ comment-id : ${{ steps.fc.outputs.comment-id }}
195+ issue-number : ${{ github.event.pull_request.number }}
196+ body : |
197+ Markdown linter report did not find any issues!
198+ _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
199+ edit-mode : replace
200+
118201# ############################ Readability Report ###################################
119202
120203 readability-report :
0 commit comments