fix workflows #23
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: Deploy MCP Staging | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "mcp/**" | |
| - "package.json" | |
| - "package-lock.json" | |
| - ".changeset/config.json" | |
| - ".github/workflows/deploy-mcp-staging.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| deployments: write | |
| concurrency: | |
| group: mcp-staging | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: "24.14.0" | |
| # Hardcoded instead of `steps.deploy.outputs.deployment-url` because | |
| # cloudflare/wrangler-action@v3 returns a malformed value for | |
| # custom-domain deploys — e.g. `mcp-staging.mcpjam.com (custom domain)` | |
| # with no scheme and a trailing suffix (wrangler-action#396). Pinning | |
| # the known hostname sidesteps that. | |
| STAGING_URL: "https://mcp-staging.mcpjam.com" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| environment: | |
| name: mcp-staging | |
| url: ${{ vars.MCP_WORKER_STAGING_URL }} | |
| steps: | |
| - name: Enforce main branch | |
| run: | | |
| if [ "${GITHUB_REF_NAME}" != "main" ]; then | |
| echo "deploy-mcp-staging.yml must run from main" >&2 | |
| exit 1 | |
| fi | |
| - name: Require Cloudflare credentials | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: | | |
| if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then | |
| echo "Missing GitHub Actions secret: CLOUDFLARE_ACCOUNT_ID" >&2 | |
| exit 1 | |
| fi | |
| if [ -z "$CLOUDFLARE_API_TOKEN" ]; then | |
| echo "Missing GitHub Actions secret: CLOUDFLARE_API_TOKEN" >&2 | |
| exit 1 | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: npm | |
| - name: Install workspace dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Build SDK package | |
| run: npm run build -w @mcpjam/sdk | |
| - name: Typecheck MCP worker | |
| run: npm run typecheck -w @mcpjam/mcp | |
| - name: Deploy staging worker | |
| id: deploy | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| workingDirectory: "mcp" | |
| command: deploy --env staging | |
| - name: Smoke test landing page | |
| run: | | |
| # First deploy onto a new custom domain can take up to ~60s for | |
| # Cloudflare to provision the edge cert and propagate the | |
| # hostname. Each probe is bounded (--connect-timeout 3 | |
| # --max-time 6) so one hung TCP/TLS handshake can't blow past | |
| # the retry budget and hold the mcp-staging concurrency slot. | |
| for attempt in $(seq 1 20); do | |
| if curl --fail --silent --show-error --connect-timeout 3 --max-time 6 "$STAGING_URL" | grep -q "MCPJam MCP"; then | |
| echo "Smoke OK on attempt $attempt" | |
| exit 0 | |
| fi | |
| echo "Attempt $attempt returned non-200 or mismatched content; retrying in 3s…" | |
| sleep 3 | |
| done | |
| echo "Staging URL never resolved correctly." >&2 | |
| exit 1 | |
| - name: Summarize staging deployment | |
| run: | | |
| echo "## ✅ MCP staging deployed" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Worker: \`mcpjam-mcp-staging\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- URL: \`$STAGING_URL\`" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- MCP endpoint: \`$STAGING_URL/mcp\`" >> "$GITHUB_STEP_SUMMARY" |