Skip to content

Commit 4258693

Browse files
authored
Merge pull request #3184 from modelcontextprotocol/adamj/readme-pr-check
Add workflow to handle README-only PRs
2 parents 1ae217d + dca1e7e commit 4258693

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: README PR Check
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
paths:
7+
- 'README.md'
8+
issue_comment:
9+
types: [created]
10+
11+
jobs:
12+
check-readme-only:
13+
if: github.event_name == 'pull_request'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
steps:
19+
- name: Check files and comment if README-only
20+
uses: actions/github-script@v7
21+
with:
22+
script: |
23+
const { owner, repo } = context.repo;
24+
const prNumber = context.payload.pull_request.number;
25+
26+
const { data: files } = await github.rest.pulls.listFiles({ owner, repo, pull_number: prNumber });
27+
28+
if (files.length !== 1 || files[0].filename !== 'README.md') {
29+
console.log('PR modifies files other than README, skipping');
30+
return;
31+
}
32+
33+
// Check if we've already commented
34+
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber });
35+
if (comments.some(c => c.user.login === 'github-actions[bot]' && c.body.includes('no longer accepting PRs to add new servers'))) {
36+
console.log('Already commented on this PR, skipping');
37+
return;
38+
}
39+
40+
await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['readme: pending'] });
41+
42+
await github.rest.issues.createComment({
43+
owner,
44+
repo,
45+
issue_number: prNumber,
46+
body: `Thanks for your contribution!
47+
48+
**We are no longer accepting PRs to add new servers to the README.** The server lists are deprecated and will eventually be removed entirely, replaced by the registry.
49+
50+
👉 **To add a new MCP server:** Please publish it to the [MCP Server Registry](https://github.com/modelcontextprotocol/registry) instead. You can browse published servers at [registry.modelcontextprotocol.io](https://registry.modelcontextprotocol.io/).
51+
52+
👉 **If this PR updates or removes an existing entry:** We do still accept these changes. Please reply with \`/i-promise-this-is-not-a-new-server\` to continue.
53+
54+
If this PR is adding a new server, please close it and submit to the registry instead.`
55+
});
56+
57+
handle-confirmation:
58+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/i-promise-this-is-not-a-new-server')
59+
runs-on: ubuntu-latest
60+
permissions:
61+
pull-requests: write
62+
steps:
63+
- name: Swap labels and minimize comments
64+
uses: actions/github-script@v7
65+
with:
66+
script: |
67+
const { owner, repo } = context.repo;
68+
const prNumber = context.payload.issue.number;
69+
70+
// Check if pending label exists
71+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number: prNumber });
72+
if (!labels.some(l => l.name === 'readme: pending')) {
73+
console.log('No pending label found, skipping');
74+
return;
75+
}
76+
77+
// Swap labels
78+
try {
79+
await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'readme: pending' });
80+
} catch (e) {}
81+
await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['readme: ready for review'] });
82+
83+
// Find the bot's original comment
84+
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber });
85+
const botComment = comments.find(c =>
86+
c.user.login === 'github-actions[bot]' &&
87+
c.body.includes('no longer accepting PRs to add new servers')
88+
);
89+
90+
// Minimize both comments via GraphQL
91+
const minimizeComment = async (nodeId) => {
92+
await github.graphql(`
93+
mutation($id: ID!) {
94+
minimizeComment(input: {subjectId: $id, classifier: RESOLVED}) {
95+
minimizedComment { isMinimized }
96+
}
97+
}
98+
`, { id: nodeId });
99+
};
100+
101+
if (botComment) {
102+
await minimizeComment(botComment.node_id);
103+
}
104+
105+
// Only minimize user's comment if it's just the command
106+
const userComment = context.payload.comment.body.trim();
107+
if (userComment === '/i-promise-this-is-not-a-new-server') {
108+
await minimizeComment(context.payload.comment.node_id);
109+
}

0 commit comments

Comments
 (0)