feat: Set up markdownlint GitHub Action for automated linting (Closes #14) #5
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: Linting | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # This identifies which files changed in the specific commit or PR | |
| - uses: tj-actions/changed-files@v47 | |
| id: changed-files | |
| with: | |
| files: '**/*.md' | |
| separator: "," | |
| # This runs the linter ONLY on the files identified above | |
| - uses: DavidAnson/markdownlint-cli2-action@v22 | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| with: | |
| globs: ${{ steps.changed-files.outputs.all_changed_files }} | |
| separator: "," | |
| fix: true | |
| # Check if anything was fixed, then Commit & Push | |
| - name: Commit and push fixes | |
| if: always() && steps.changed-files.outputs.any_changed == 'true' | |
| run: | | |
| # Configure the bot's identity | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # Check if the linter modified any files | |
| if [[ -n $(git status -s) ]]; then | |
| git add . | |
| git commit -m "style: auto-fix markdown formatting" | |
| git push origin HEAD:${{ github.head_ref }} | |
| fi |