fix: badges can grow #2829
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | |
| }); | |
| } |