diff --git a/.github/workflows/htmlproofer.yml b/.github/workflows/htmlproofer.yml new file mode 100644 index 0000000000..382cc2bfee --- /dev/null +++ b/.github/workflows/htmlproofer.yml @@ -0,0 +1,49 @@ +# .github/workflows/check-links.yml + +name: Check Documentation Links + +on: + pull_request: + branches: [main] + paths: + - 'docs/**' + - 'mkdocs.yml' + - 'requirements.txt' + push: + branches: [main] + workflow_dispatch: + +jobs: + check-links: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install mkdocs-htmlproofer-plugin + + - name: Check links + run: | + # Run build and check for broken links + mkdocs build 2>&1 | tee build.log + + # Fail if any broken links found + if grep -q "invalid url" build.log; then + echo "❌ Broken links found!" + grep "invalid url" build.log + exit 1 + fi + + echo "✅ All links are valid!" \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6342971778..0c7fab1308 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,14 @@ repos: - repo: https://github.com/crate-ci/typos - rev: v1.33.1 + rev: v1.34.0 hooks: - id: typos - args: ["--config", ".typos.toml"] \ No newline at end of file + args: ["--config", ".typos.toml"] + - repo: local + hooks: + - id: check-docs-links + name: Check documentation links + entry: mkdocs build + language: system + files: '^docs/.*\.(md|markdown)$' + pass_filenames: false \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 33845a989b..61298b9bb1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -285,6 +285,16 @@ plugins: - components/anomaly-support/* - components/comparators/* - components/general-props/* + - htmlproofer: + raise_error: True + validate_external_urls: True + ignore_urls: + - "http://localhost.*" + - "http://127.0.0.1.*" + - "#" + - "https://your-company.atlan.com" + - "mailto://hello@qualytics.co" + - "../print_page/" - git-revision-date-localized - include-markdown - macros diff --git a/requirements.txt b/requirements.txt index f2db8880b9..d027a3be03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ -mkdocs-material==9.5.50 mkdocs-exclude==1.0.2 mkdocs-git-revision-date-localized-plugin==1.2.6 +mkdocs-htmlproofer-plugin==1.3.0 mkdocs-include-markdown-plugin==6.0.2 mkdocs-macros-plugin==1.3.7 +mkdocs-material==9.5.50 mkdocs-print-site-plugin==2.7.3 mkdocs-redirects==1.2.2 pre-commit==3.8.0 \ No newline at end of file