Skip to content

[AUTO NEW TOOL]

[AUTO NEW TOOL] #12

Workflow file for this run

name: Add Tool from Issue
on:
issues:
types: [opened, reopened]
issue_comment:
types: [created]
workflow_dispatch:
inputs:
issue_number:
description: 'Issue number to process'
required: true
type: number
permissions:
contents: write
issues: write
jobs:
request-approval:
if: |
github.event_name == 'issues' &&
startsWith(github.event.issue.title, '[AUTO NEW TOOL]')
runs-on: ubuntu-latest
steps:
- name: Ask maintainer to review
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: [
'@Joe-Huber please review this tool submission.',
'',
'If it looks good, comment `/approve` on this issue to add it to tools.json and regenerate the README.',
'Only approvals from @Joe-Huber will trigger the commit workflow.'
].join('\n')
})
add-tool:
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' &&
github.event.issue != null &&
startsWith(github.event.issue.title, '[AUTO NEW TOOL]') &&
github.event.comment.user.login == 'Joe-Huber' &&
github.event.comment.body == '/approve')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: pip install PyGithub
- name: Set issue number
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "ISSUE_NUMBER=${{ github.event.inputs.issue_number }}" >> $GITHUB_ENV
else
echo "ISSUE_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
fi
- name: Process issue and update tools
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ github.repository }}
run: python scripts/add_tool.py
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md tools.json
git diff --staged --quiet || (git commit -m "bot: add new tool from issue #${ISSUE_NUMBER}" && git push)