Skip to content

New Doc: Add remote MCP servers #90

New Doc: Add remote MCP servers

New Doc: Add remote MCP servers #90

name: Check Redirects for Deleted Pages
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "app/**/*.md"
- "app/**/*.mdx"
- "next.config.ts"
permissions:
contents: read
pull-requests: write
jobs:
check-redirects:
name: Verify Deleted Pages Have Redirects
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for branch comparison
- name: Fetch base branch
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Check for missing redirects
id: check
run: |
set -o pipefail
pnpm check-redirects ${{ github.base_ref }} 2>&1 | tee redirect-check-output.txt
continue-on-error: true
- name: Comment on PR if redirects are missing
if: steps.check.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('redirect-check-output.txt', 'utf8');
// Extract the missing redirects and suggestions from output
const body = `## 🔗 Missing Redirects Detected
This PR deletes markdown files that don't have corresponding redirects in \`next.config.ts\`.
When you delete a page, you must add a redirect to prevent broken links for users who have bookmarked the old URL.
<details>
<summary>📋 View Details</summary>
\`\`\`
${output}
\`\`\`
</details>
### How to fix
1. Open \`next.config.ts\`
2. Find the \`redirects()\` function
3. Add redirect entries for each deleted file (see suggestions above)
4. Push the changes
---
*This check ensures we maintain URL stability for our documentation.*`;
// Check if we already commented
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Missing Redirects Detected')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Remove outdated comment if check passes
if: steps.check.outcome == 'success'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Missing Redirects Detected')
);
if (botComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
});
}
- name: Fail if redirects are missing
if: steps.check.outcome == 'failure'
run: |
echo "❌ Missing redirects for deleted pages. See PR comment for details."
exit 1