Files
TX-Ultimate-Easy/.github/workflows/validate_markdown.yml
Edward Firmo e944cd2c21 Remove reference to tj-actions
Security reasons
2025-03-15 18:19:32 +01:00

76 lines
2.0 KiB
YAML

---
name: Validate Markdown
# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- '**/*.md'
push:
paths:
- '**/*.md'
workflow_dispatch:
jobs:
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures full commit history for diff
- name: Identify changed files
id: changed-files
run: |
BASE=${{ github.event.before }}
HEAD=${{ github.sha }}
FILES=$(git diff --name-only $BASE $HEAD -- '**/*.md' | tr '\n' ',')
echo "changed_files=$FILES" >> $GITHUB_ENV
if [[ -n "$FILES" ]]; then
echo "any_changed=true" >> $GITHUB_ENV
else
echo "any_changed=false" >> $GITHUB_ENV
fi
- name: Markdown Lint
uses: DavidAnson/markdownlint-cli2-action@v14
if: env.any_changed == 'true'
with:
globs: ${{ env.changed_files }}
separator: ","
config: '.rules/.markdownlint.jsonc'
fix: true
markdown-links:
name: Check links
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Identify changed files
id: changed-files
run: |
BASE=${{ github.event.before }}
HEAD=${{ github.sha }}
FILES=$(git diff --name-only $BASE $HEAD -- '**/*.md' | tr '\n' ',')
echo "changed_files=$FILES" >> $GITHUB_ENV
if [[ -n "$FILES" ]]; then
echo "any_changed=true" >> $GITHUB_ENV
else
echo "any_changed=false" >> $GITHUB_ENV
fi
- name: Markdown links
uses: gaurav-nelson/github-action-markdown-link-check@v1
if: env.any_changed == 'true'
with:
check-modified-files-only: yes
config-file: '.rules/mlc_config.json'
base-branch: 'main'
...