Skip to content

testing with brave search #14

testing with brave search

testing with brave search #14

Workflow file for this run

name: Scrape and Update Repo
permissions:
contents: write
pull-requests: write
issues: write
on:
issues:
types: [labeled]
jobs:
scrape-and-update:
runs-on: ubuntu-latest
if: github.event.label.name == 'new-server' # Trigger only on 'new-server' label
steps:
- name: Check if user is authorized
env:
SENDER: ${{ github.event.sender.login }}
run: |
# Custom list of authorized users (GitHub usernames)
AUTHORIZED_USERS="jeremy-dai-txyz JoJoJoJoJoJoJo niechen"
if echo "$AUTHORIZED_USERS" | grep -q -w "$SENDER"; then
echo "User $SENDER is authorized"
else
echo "User $SENDER is not authorized"
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests openai jsonschema mcp loguru pydantic ruamel-yaml
- name: Create local directory
run: mkdir -p local
- name: Run Script with Issue Body
id: run_script
env:
ISSUE_BODY: ${{ github.event.issue.body }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
shell: /usr/bin/bash -e {0}
continue-on-error: true
run: |
echo "Running get_manifest.py with issue body"
mkdir -p local
if python scripts/get_manifest.py "$ISSUE_BODY"; then
echo "script_success=true" >> $GITHUB_OUTPUT
else
echo "script_success=false" >> $GITHUB_OUTPUT
fi
- name: Comment on issue
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = context.issue.number;
const run_id = context.runId;
const repo = context.repo;
const run_url = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${run_id}`;
await github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: issue_number,
body: `🤖 Processing your MCP server submission...\n\nTrack progress here: [GitHub Action Run #${run_id}](${run_url})`
});
- name: Create and push new branch
if: steps.run_script.outputs.script_success == 'true'
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: /usr/bin/bash -e {0}
run: |
# Create a unique branch name with issue number
BRANCH_NAME="scrape-issue-$ISSUE_NUMBER"
git config user.name "GitHub Action"
git config user.email "[email protected]"
git checkout -b "$BRANCH_NAME"
git add -f local/ mcp-registry/ # Add all files generated by the script
git commit -m "Update repo with server manifest from issue #$ISSUE_NUMBER" || echo "No changes to commit"
git push origin "$BRANCH_NAME" --force # Push to the new branch
# Create PR directly using GitHub API instead of peter-evans/create-pull-request
PR_TITLE="Add server from issue #$ISSUE_NUMBER"
PR_BODY="Automated PR from issue #$ISSUE_NUMBER\n\nServer URL: $ISSUE_BODY"
# Check if PR already exists
PR_EXISTS=$(gh pr list --head "$BRANCH_NAME" --json number --jq 'length')
if [ "$PR_EXISTS" = "0" ]; then
# Create PR if it doesn't exist
PR_URL=$(gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "$BRANCH_NAME")
echo "pr_number=$(echo $PR_URL | grep -o '[0-9]*$')" >> $GITHUB_ENV
echo "pr_url=$PR_URL" >> $GITHUB_ENV
else
# Get PR number if it exists
PR_DATA=$(gh pr list --head "$BRANCH_NAME" --json number,url --jq '.[0]')
echo "pr_number=$(echo $PR_DATA | jq -r '.number')" >> $GITHUB_ENV
echo "pr_url=$(echo $PR_DATA | jq -r '.url')" >> $GITHUB_ENV
fi
- name: Setup GitHub CLI
if: steps.run_script.outputs.script_success == 'true'
uses: cli/cli-action@v1
- name: Comment on issue with success
if: steps.run_script.outputs.script_success == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = context.issue.number;
const repo = context.repo;
const pr_number = process.env.pr_number;
const pr_url = process.env.pr_url;
let body = '';
if (pr_number) {
body = `✅ Processing complete!\n\nA pull request has been created with the server manifest: [PR #${pr_number}](${pr_url})`;
} else {
body = `⚠️ Processing completed, but no pull request was created. Please check the action logs for details.`;
}
await github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: issue_number,
body: body
});
- name: Comment on issue with failure
if: steps.run_script.outputs.script_success == 'false'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = context.issue.number;
const repo = context.repo;
const run_id = context.runId;
const run_url = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${run_id}`;
await github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: issue_number,
body: `❌ Failed to process the server manifest. Please check the [action logs](${run_url}) for details.`
});