Skip to content

Commit

Permalink
Update linter
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed Jan 10, 2025
1 parent df4480a commit 48c6123
Showing 1 changed file with 7 additions and 40 deletions.
47 changes: 7 additions & 40 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,75 +121,42 @@ jobs:
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}}
container:
image: davidanson/markdownlint-cli2

steps:
- name: Checkout files
uses: actions/checkout@v4

- run: |
mkdir -p check_reports
curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \
-o resources/.markdownlint-cli2.jsonc
markdownlint-cli2 "**/*.md" "#node_modules" \
>> check_reports/markdown_lint_report.txt 2>&1
# Commit the rendered bookdown files
- name: Commit markdown report to preview branch
id: commit
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
error_num=$(cat check_reports/markdown_lint_report.txt | wc -l)
error_num="$((error_num-12))"
echo "markdown_issues=$error_num" >> $GITHUB_OUTPUT
git add check_reports/markdown_lint_report.txt --force
git commit -m 'Add markdown report' || echo "No report to commit"
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push --force || echo "No report to commit"
shell: bash
- uses: DavidAnson/markdownlint-cli2-action@v19
with:
globs: '**/*.md'
continue-on-error: true

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes:
body-includes: Markdown linter

- name: Build components of the comment
id: build-components
run: |
report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/check_reports/markdown_lint_report.txt")
report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}")
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo ${{steps.commit.outputs.markdown_issues}}
- name: Create or update comment
if: steps.commit.outputs.markdown_issues > 4
- name: Create or uxpdate comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
[Markdown linter report here](${{ steps.build-components.outputs.report_link }})
$(error_num) potential errors reported
_Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

- name: Comment if no changes
if: steps.commit.outputs.markdown_issues > 4
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Markdown linter report did not find any issues!
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

############################# Readability Report ###################################

readability-report:
Expand Down

0 comments on commit 48c6123

Please sign in to comment.