diff --git a/.github/workflows/markdown-links.yml b/.github/workflows/markdown-links.yml new file mode 100644 index 000000000..d9dfcaca7 --- /dev/null +++ b/.github/workflows/markdown-links.yml @@ -0,0 +1,13 @@ +name: Check Markdown links + +on: push + +jobs: + markdown-link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + config-file: tools/markdown-link-check.json + use-quiet-mode: yes diff --git a/tools/markdown-link-check.json b/tools/markdown-link-check.json new file mode 100644 index 000000000..2daa98ab1 --- /dev/null +++ b/tools/markdown-link-check.json @@ -0,0 +1,5 @@ +{ + "ignorePatterns": [ + {"pattern": "^https://github.com/icinga/icinga2/issues/"} + ] +} diff --git a/tools/markdown-link-check.sh b/tools/markdown-link-check.sh new file mode 100755 index 000000000..c77740b3d --- /dev/null +++ b/tools/markdown-link-check.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +PATH="$(pwd)/node_modules/.bin:${PATH}" + +errors=0 + +while read -r file; do + if ! markdown-link-check --config tools/markdown-link-check.json --quiet "$file"; then + (( errors++ )) || true + fi +done < <(find -name \*.md) + +if [[ $errors -gt 0 ]]; then + echo + echo "Found ${errors} files with errors!" + echo + exit 1 +fi