Skip to content

fix openrouter binding #273

fix openrouter binding

fix openrouter binding #273

name: Deploy MCPs (Preview)
on:
pull_request:
branches:
- main
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
mcps: ${{ steps.detect.outputs.mcps }}
has_changes: ${{ steps.detect.outputs.has_changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for git diff
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Detect changed MCPs
id: detect
run: |
# For PRs, compare against the base branch
BASE_REF="origin/${{ github.base_ref }}"
HEAD_REF="${{ github.event.pull_request.head.sha }}"
# Detect changed MCPs
CHANGED_MCPS=$(bun run scripts/detect-changed-mcps.ts "$BASE_REF" "$HEAD_REF")
echo "Changed MCPs: $CHANGED_MCPS"
# Set outputs
echo "mcps=$CHANGED_MCPS" >> $GITHUB_OUTPUT
# Check if array is not empty
if [ "$CHANGED_MCPS" = "[]" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
deploy:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
mcp: ${{ fromJSON(needs.detect-changes.outputs.mcps) }}
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install Deco CLI
run: bun install -g deco-cli
- name: Deploy ${{ matrix.mcp }} (Preview)
id: deploy
run: |
bun run scripts/deploy.ts ${{ matrix.mcp }} --preview 2>&1 | tee deploy_output.txt
# Extract preview URL from output
PREVIEW_URL=$(grep -o 'https://[^ ]*' deploy_output.txt | head -1 || echo "")
echo "preview_url=$PREVIEW_URL" >> $GITHUB_OUTPUT
echo "mcp_name=${{ matrix.mcp }}" >> $GITHUB_OUTPUT
env:
DECO_DEPLOY_TOKEN: ${{ secrets.DECO_DEPLOY_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GOOGLE_GENAI_API_KEY: ${{ secrets.GOOGLE_GENAI_API_KEY }}
NANOBANANA_API_KEY: ${{ secrets.NANOBANANA_API_KEY }}
PINECONE_TOKEN: ${{ secrets.PINECONE_TOKEN }}
PINECONE_INDEX: ${{ secrets.PINECONE_INDEX }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
APIFY_API_TOKEN: ${{ secrets.APIFY_API_TOKEN }}
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }}
META_ACCESS_TOKEN: ${{ secrets.META_ACCESS_TOKEN }}
- name: Save deployment info
if: steps.deploy.outputs.preview_url
run: |
mkdir -p deployment-info
echo "${{ steps.deploy.outputs.mcp_name }}|${{ steps.deploy.outputs.preview_url }}" > deployment-info/${{ matrix.mcp }}.txt
- name: Upload deployment info
if: steps.deploy.outputs.preview_url
uses: actions/upload-artifact@v4
with:
name: deployment-${{ matrix.mcp }}
path: deployment-info/${{ matrix.mcp }}.txt
retention-days: 1
comment-pr:
needs: [detect-changes, deploy]
if: always() && needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Download all deployment artifacts
uses: actions/download-artifact@v4
with:
path: deployment-info
continue-on-error: true
- name: Comment PR with preview URLs
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
// Read all deployment info files
const deploymentInfoDir = 'deployment-info';
let deployments = [];
try {
const artifacts = fs.readdirSync(deploymentInfoDir);
for (const artifact of artifacts) {
const artifactPath = path.join(deploymentInfoDir, artifact);
if (fs.statSync(artifactPath).isDirectory()) {
const files = fs.readdirSync(artifactPath);
for (const file of files) {
const filePath = path.join(artifactPath, file);
const content = fs.readFileSync(filePath, 'utf8').trim();
const [mcpName, previewUrl] = content.split('|');
if (mcpName && previewUrl) {
deployments.push({ mcpName, previewUrl });
}
}
}
}
} catch (error) {
console.log('No deployment info found or error reading:', error);
}
// Build comment
let comment = '## 🚀 Preview Deployments Ready!\n\n';
if (deployments.length > 0) {
comment += 'Your changes have been deployed to preview environments:\n\n';
for (const { mcpName, previewUrl } of deployments) {
comment += `### 📦 \`${mcpName}\`\n`;
comment += `**🔗 [View Preview](${previewUrl})**\n\n`;
}
comment += 'These previews will be automatically updated with new commits to this PR.\n\n';
} else {
comment += '⚠️ No preview URLs were generated. Check the workflow logs for details.\n\n';
}
comment += `---\n<sub>Deployed from commit: \`${context.sha.substring(0, 7)}\`</sub>`;
// Check if we already have a preview comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComment = comments.find(comment =>
comment.body.includes('🚀 Preview Deployments Ready!')
);
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}