Skip to content

Commit 4d7649a

Browse files
committed
chore: add broken-links check
1 parent f6a6b2a commit 4d7649a

File tree

3 files changed

+105
-2
lines changed

3 files changed

+105
-2
lines changed

.github/workflows/broken-links.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Check Broken Links
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'mintlify/**/*.mdx'
7+
types: [opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
check-broken-links:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '18'
24+
25+
- name: Install Mintlify CLI
26+
run: npm install -g mintlify
27+
28+
- name: Check for broken links
29+
id: broken-links
30+
working-directory: mintlify
31+
run: |
32+
# Run mint broken-links and capture output
33+
OUTPUT=$(mint broken-links 2>&1 || true)
34+
35+
# Filter out /api-reference/ false positives
36+
FILTERED_OUTPUT=$(echo "$OUTPUT" | grep -v "/api-reference/" || true)
37+
38+
# Count real broken links (excluding the summary line)
39+
BROKEN_COUNT=$(echo "$FILTERED_OUTPUT" | grep -E "^\s+/" | wc -l || echo "0")
40+
41+
# Save results to GitHub outputs
42+
echo "broken_count=$BROKEN_COUNT" >> $GITHUB_OUTPUT
43+
44+
# Save filtered output to file for PR comment
45+
if [ "$BROKEN_COUNT" -gt 0 ]; then
46+
echo "$FILTERED_OUTPUT" > broken_links_output.txt
47+
echo "has_broken_links=true" >> $GITHUB_OUTPUT
48+
else
49+
echo "✅ No broken links found" > broken_links_output.txt
50+
echo "has_broken_links=false" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Comment on PR
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
const fs = require('fs');
58+
const brokenCount = '${{ steps.broken-links.outputs.broken_count }}';
59+
const hasBrokenLinks = '${{ steps.broken-links.outputs.has_broken_links }}' === 'true';
60+
61+
let comment;
62+
if (hasBrokenLinks) {
63+
const output = fs.readFileSync('mintlify/broken_links_output.txt', 'utf8');
64+
comment = `## 🔗 Broken Links Found\n\n${brokenCount} broken link(s) detected:\n\n\`\`\`\n${output}\`\`\`\n\n⚠️ Please fix these broken links before merging.`;
65+
} else {
66+
comment = `## ✅ Link Check Passed\n\nNo broken links found in the documentation files.`;
67+
}
68+
69+
// Find existing comment
70+
const { data: comments } = await github.rest.issues.listComments({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
issue_number: context.issue.number,
74+
});
75+
76+
const existingComment = comments.find(comment =>
77+
comment.body.includes('🔗 Broken Links Found') ||
78+
comment.body.includes('✅ Link Check Passed')
79+
);
80+
81+
if (existingComment) {
82+
// Update existing comment
83+
await github.rest.issues.updateComment({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
comment_id: existingComment.id,
87+
body: comment
88+
});
89+
} else {
90+
// Create new comment
91+
await github.rest.issues.createComment({
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
issue_number: context.issue.number,
95+
body: comment
96+
});
97+
}
98+
99+
- name: Fail if broken links found
100+
if: steps.broken-links.outputs.has_broken_links == 'true'
101+
run: |
102+
echo "❌ ${{ steps.broken-links.outputs.broken_count }} broken link(s) found"
103+
exit 1

mintlify/change-database/troubleshoot.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Troubleshoot
66

77
This happens if a migration version has already completed successfully and you are trying to apply the same version. Once the migration is successful, its version string is occupied and can't be reused. You can still retry the failed migration.
88

9-
This error is more common in GitOps flow when you try to modify an existing migration file. Refer to the [GitOps troubleshoot](/change-database/troubleshoot#duplicate-version)
9+
This error is more common in GitOps flow when you try to modify an existing migration file. Refer to the [GitOps troubleshoot](/change-database/troubleshoot1#duplicate-version)
1010
to learn the correct workflow.
1111

1212
## PostgreSQL

mintlify/snippets/install/install-upgrade.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Install and Upgrade
44

55
## ⚙️ Install and Upgrade
66

7-
- Fresh install: [/get-started/self-host/deploy-with-docker](/get-started/self-host/deploy-with-docker)
7+
- Fresh install: [/get-started/self-host/deploy-with-docker](/get-started/self-2host/deploy-with-docker)
88

99
- Upgrade: [/get-started/self-host/upgrade](/get-started/self-host/upgrade)
1010

0 commit comments

Comments
 (0)