testing with brave search #13
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: 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 }} | |
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 | |
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Create Pull Request | |
id: create_pr | |
if: steps.run_script.outputs.script_success == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Add server from issue #${{ github.event.issue.number }}" | |
title: "Add server from issue #${{ github.event.issue.number }}" | |
body: | | |
Automated PR from issue #${{ github.event.issue.number }} | |
Server URL: ${{ github.event.issue.body }} | |
branch: ${{ env.branch_name }} | |
base: main | |
- 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 = '${{ steps.create_pr.outputs.pull-request-number }}'; | |
const pr_url = pr_number ? `https://github.com/${repo.owner}/${repo.repo}/pull/${pr_number}` : ''; | |
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.` | |
}); |