Skip to content

Merge pull request #97 from OpenVoxProject/runner_needs_pandoc #21

Merge pull request #97 from OpenVoxProject/runner_needs_pandoc

Merge pull request #97 from OpenVoxProject/runner_needs_pandoc #21

Workflow file for this run

---
name: Markdown Lint
on:
pull_request: {}
push:
branches:
- master
workflow_dispatch: {}
permissions:
contents: read
jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # required to resolve base.sha for PR diff comparison
- name: Find changed Markdown files
id: changed-markdown
shell: bash
run: |
case "${GITHUB_EVENT_NAME}" in
pull_request)
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${GITHUB_SHA}"
;;
push)
base_sha="${{ github.event.before }}"
head_sha="${GITHUB_SHA}"
;;
*)
# workflow_dispatch: lints only files changed in the most recent commit, not the full branch
# || true handles initial commits with no parent
base_sha="$(git rev-parse "${GITHUB_SHA}^" 2>/dev/null || true)"
head_sha="${GITHUB_SHA}"
;;
esac
if [[ -z "${base_sha}" || "${base_sha}" =~ ^0+$ ]]; then
base_sha="$(git rev-list --max-parents=0 "${head_sha}")"
fi
git diff --name-only --diff-filter=ACMRT "${base_sha}" "${head_sha}" -- '*.md' '*.markdown' > changed-markdown-files.txt
if [[ -s changed-markdown-files.txt ]]; then
echo "has_files=true" >> "${GITHUB_OUTPUT}"
{
echo 'files<<EOF'
cat changed-markdown-files.txt
echo 'EOF'
} >> "${GITHUB_OUTPUT}"
else
echo "has_files=false" >> "${GITHUB_OUTPUT}"
fi
- name: No changed Markdown files
if: steps.changed-markdown.outputs.has_files != 'true'
run: echo "No changed Markdown files to lint."
- uses: DavidAnson/markdownlint-cli2-action@v22
if: steps.changed-markdown.outputs.has_files == 'true'
with:
globs: ${{ steps.changed-markdown.outputs.files }}