Add GitHub action to run markdownlint on PRs #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Markdown lint | |
| on: | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| markdownlint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed markdown files | |
| id: changed | |
| run: | | |
| files=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD -- '*.md') | |
| if [ -z "$files" ]; then | |
| echo "files=" >> "$GITHUB_OUTPUT" | |
| echo "No changed markdown files found." | |
| else | |
| echo "files<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$files" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| echo "Changed markdown files:" | |
| echo "$files" | |
| fi | |
| - name: Install markdownlint | |
| if: steps.changed.outputs.files != '' | |
| run: sudo apt-get install -y markdownlint | |
| - name: Run markdownlint | |
| if: steps.changed.outputs.files != '' | |
| run: echo "${{ steps.changed.outputs.files }}" | xargs mdl |