Rename README.md to index.md #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Sync Nav, Check Links, and Comment on PRs | |
| on: | |
| push: | |
| paths: | |
| - "docs/**" | |
| - "README.md" | |
| - "scripts/**" | |
| - ".github/workflows/nav-sync.yml" | |
| - ".github/mlc-config.json" | |
| pull_request: | |
| paths: | |
| - "docs/**" | |
| - "README.md" | |
| - "scripts/**" | |
| - ".github/workflows/nav-sync.yml" | |
| - ".github/mlc-config.json" | |
| workflow_dispatch: {} | |
| jobs: | |
| nav: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Python deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyyaml | |
| - name: Generate navigation | |
| run: python scripts/nav_sync.py | |
| - name: Commit nav changes (if any) | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore(nav): auto-sync README navigation" | |
| linkcheck: | |
| needs: nav | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (post-nav) | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install markdown-link-check | |
| run: npm install -g markdown-link-check@3 | |
| - name: Prepare report folder | |
| run: mkdir -p .reports | |
| - name: Run link check | |
| shell: bash | |
| run: | | |
| echo "# 🔗 Markdown Link Check Report" > .reports/link-check.md | |
| echo "" >> .reports/link-check.md | |
| echo "_Auto-generated by CI. Broken links will be listed below._" >> .reports/link-check.md | |
| echo "" >> .reports/link-check.md | |
| status=0 | |
| while IFS= read -r -d '' file; do | |
| echo "Checking: $file" | |
| echo "## File: \`$file\`" >> .reports/link-check.md | |
| markdown-link-check -p -q -c .github/mlc-config.json "$file" >> .reports/link-check.md 2>&1 || status=1 | |
| echo "" >> .reports/link-check.md | |
| done < <(git ls-files '*.md' -z) | |
| echo "STATUS=$status" >> $GITHUB_ENV | |
| - name: Upload link check artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: link-check-report | |
| path: .reports/link-check.md | |
| - name: Post sticky comment with link report | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| recreate: true | |
| path: .reports/link-check.md | |
| - name: Fail if broken links found | |
| if: ${{ env.STATUS == '1' }} | |
| run: | | |
| echo "Broken links detected. See the PR comment and artifact for details." | |
| exit 1 |