|
| 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: [ |
| 47 | + 'Thanks for your contribution!', |
| 48 | + '', |
| 49 | + '**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.', |
| 50 | + '', |
| 51 | + '👉 **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/).', |
| 52 | + '', |
| 53 | + '👉 **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.', |
| 54 | + '', |
| 55 | + 'If this PR is adding a new server, please close it and submit to the registry instead.', |
| 56 | + ].join('\n'), |
| 57 | + }); |
| 58 | +
|
| 59 | + handle-confirmation: |
| 60 | + if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/i-promise-this-is-not-a-new-server') |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + pull-requests: write |
| 64 | + steps: |
| 65 | + - name: Swap labels and minimize comments |
| 66 | + uses: actions/github-script@v7 |
| 67 | + with: |
| 68 | + script: | |
| 69 | + const { owner, repo } = context.repo; |
| 70 | + const prNumber = context.payload.issue.number; |
| 71 | +
|
| 72 | + // Check if pending label exists |
| 73 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number: prNumber }); |
| 74 | + if (!labels.some(l => l.name === 'readme: pending')) { |
| 75 | + console.log('No pending label found, skipping'); |
| 76 | + return; |
| 77 | + } |
| 78 | +
|
| 79 | + // Swap labels |
| 80 | + try { |
| 81 | + await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'readme: pending' }); |
| 82 | + } catch (e) {} |
| 83 | + await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['readme: ready for review'] }); |
| 84 | +
|
| 85 | + // Find the bot's original comment |
| 86 | + const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: prNumber }); |
| 87 | + const botComment = comments.find(c => |
| 88 | + c.user.login === 'github-actions[bot]' && |
| 89 | + c.body.includes('no longer accepting PRs to add new servers') |
| 90 | + ); |
| 91 | +
|
| 92 | + // Minimize both comments via GraphQL |
| 93 | + const minimizeComment = async (nodeId) => { |
| 94 | + await github.graphql(` |
| 95 | + mutation($id: ID!) { |
| 96 | + minimizeComment(input: {subjectId: $id, classifier: RESOLVED}) { |
| 97 | + minimizedComment { isMinimized } |
| 98 | + } |
| 99 | + } |
| 100 | + `, { id: nodeId }); |
| 101 | + }; |
| 102 | +
|
| 103 | + if (botComment) { |
| 104 | + await minimizeComment(botComment.node_id); |
| 105 | + } |
| 106 | +
|
| 107 | + // Only minimize user's comment if it's just the command |
| 108 | + const userComment = context.payload.comment.body.trim(); |
| 109 | + if (userComment === '/i-promise-this-is-not-a-new-server') { |
| 110 | + await minimizeComment(context.payload.comment.node_id); |
| 111 | + } |
0 commit comments