-
Notifications
You must be signed in to change notification settings - Fork 45
163 lines (149 loc) · 5.78 KB
/
mcp-vercel.yml
File metadata and controls
163 lines (149 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Vercel MCP-Deploy
on:
push:
branches:
- develop
paths:
- '.github/workflows/mcp-vercel.yml'
- 'packages/samples/react/**'
- 'packages/tools/mcp/**'
- 'packages/components/**'
pull_request:
paths:
- '.github/workflows/mcp-vercel.yml'
- 'packages/components/**'
- 'packages/samples/react/**'
- 'packages/tools/mcp/**'
workflow_dispatch:
concurrency:
group: 'mcp-vercel-${{ github.ref }}'
cancel-in-progress: true
permissions:
attestations: write
contents: read
id-token: write
issues: write
pull-requests: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
PNPM_CACHE_FOLDER: .pnpm
VERCEL_ORG_ID: ${{ secrets.VERCEL_MCP_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_MCP_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_MCP_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setup pnpm workspace
uses: ./.github/actions/pnpm-setup
- name: Build MCP dependencies
run: |
echo "🧱 Building MCP workspace dependencies..."
pnpm --filter @public-ui/mcp run build:deps
- name: Build MCP package
run: |
echo "🔨 Building MCP package..."
pnpm --filter @public-ui/mcp build
- name: Verify MCP build artifacts
working-directory: packages/tools/mcp
run: |
echo "📊 Checking built artifacts..."
echo "Dist directory contents:"
ls -la dist/ || echo "No dist directory found!"
echo ""
echo "Checking for required files:"
test -f dist/data.mjs && echo "✅ dist/data.mjs exists" || echo "❌ dist/data.mjs missing"
test -f dist/search.mjs && echo "✅ dist/search.mjs exists" || echo "❌ dist/search.mjs missing"
test -f dist/mcp.mjs && echo "✅ dist/mcp.mjs exists" || echo "❌ dist/mcp.mjs missing"
test -f shared/sample-index.json && echo "✅ shared/sample-index.json exists" || echo "❌ shared/sample-index.json missing"
echo ""
echo "Sample index stats:"
jq '.entries | length' shared/sample-index.json || echo "Could not read sample-index.json"
echo ""
echo "API directory:"
ls -la api/ || echo "No API directory found!"
- name: Strip workspace-only dependencies for Vercel
working-directory: packages/tools/mcp
run: |
echo "🧹 Preparing package.json for Vercel..."
node <<'NODE'
const fs = require('fs');
const path = require('path');
const pkgPath = path.resolve('package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
if (pkg.dependencies && pkg.dependencies['@public-ui/components']) {
console.log('Removing @public-ui/components dependency before deployment');
delete pkg.dependencies['@public-ui/components'];
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
} else {
console.log('No @public-ui/components dependency found; nothing to strip.');
}
NODE
pnpm exec prettier --write package.json
- name: Attest MCP build outputs
uses: actions/attest-build-provenance@v4
with:
subject-path: |
packages/tools/mcp/api
packages/tools/mcp/dist
packages/tools/mcp/shared/sample-index.json
- name: Deploy to Vercel (production)
id: deploy_prod
if: github.ref == 'refs/heads/develop' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
working-directory: packages/tools/mcp
run: |
set -eo pipefail
echo "🚀 Deploying pre-built package to Vercel..."
DEPLOY_URL=$(pnpm dlx vercel@latest deploy --prod --yes --token "$VERCEL_TOKEN" | tail -n1)
echo "url=${DEPLOY_URL}" >> "$GITHUB_OUTPUT"
echo "Production deployment available at ${DEPLOY_URL}"
- name: Deploy to Vercel (preview)
id: deploy_preview
if: github.event_name == 'pull_request'
working-directory: packages/tools/mcp
run: |
set -eo pipefail
echo "🚀 Deploying pre-built package to Vercel..."
DEPLOY_URL=$(pnpm dlx vercel@latest deploy --yes --token "$VERCEL_TOKEN" | tail -n1)
echo "url=${DEPLOY_URL}" >> "$GITHUB_OUTPUT"
echo "Preview deployment available at ${DEPLOY_URL}"
- name: Share preview URL in PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v8
env:
PREVIEW_URL: ${{ steps.deploy_preview.outputs.url }}
with:
script: |
const marker = '<!-- mcp-vercel-preview -->';
const url = process.env.PREVIEW_URL;
if (!url) {
core.setFailed('Missing Vercel preview URL');
return;
}
const body = `${marker}\n🚀 MCP preview deployed to Vercel: ${url}`;
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
});
const existing = comments.find((comment) => comment.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}