diff --git a/.github/workflows/link-check.yaml b/.github/workflows/link-check.yaml new file mode 100644 index 0000000..2d0f0e4 --- /dev/null +++ b/.github/workflows/link-check.yaml @@ -0,0 +1,24 @@ +--- +name: link-check +on: # yamllint disable-line rule:truthy + # Schedule check each day at 8 UTC + schedule: [{cron: "0 8 * * *"}] + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + markdown-link-check: + name: Markdown link check + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Check markdown links + uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + file-path: './README.md' + config-file: './mlc_config.json' diff --git a/Taskfile.yaml b/Taskfile.yaml index a3a610f..ac625ed 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -20,6 +20,10 @@ tasks: cmds: - task: awesome-lint - task: yamllint + linkcheck: + desc: Check for dead links + cmds: + - ./scripts/linkcheck.sh render: desc: Render README.md cmds: diff --git a/mlc_config.json b/mlc_config.json new file mode 100644 index 0000000..d0acbcf --- /dev/null +++ b/mlc_config.json @@ -0,0 +1,3 @@ +{ + "aliveStatusCodes": [200, 206, 403, 429] +} diff --git a/scripts/linkcheck.sh b/scripts/linkcheck.sh new file mode 100755 index 0000000..7cb2035 --- /dev/null +++ b/scripts/linkcheck.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +set -o pipefail +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd ) +readonly DIR +for f in $(find "${DIR}" -name \*.md); do + docker run --rm -v /:/tmp:ro -i -w /tmp ghcr.io/tcort/markdown-link-check:stable "/tmp${f}" -c "/tmp${DIR}/mlc_config.json" || exit 1 +done