Files
mcp-use__mcp-use/.github/workflows/pr-labeler.yml
pietrozullo 7f94457baf label PRs
2025-12-13 09:23:51 +01:00

53 lines
1.6 KiB
YAML

name: PR Auto Label (changed files)
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Apply labels based on changed files OR PR title keywords
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request
if (!pr) throw new Error('No pull_request payload found.')
const title = (pr.title ?? '').toLowerCase()
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
})
const paths = files.map(f => f.filename)
const touchesPython = paths.some(p => p.startsWith('libraries/python/'))
const touchesTypeScript = paths.some(p => p.startsWith('libraries/typescript/'))
const wantPython = touchesPython || title.includes('python')
const wantTypeScript = touchesTypeScript || title.includes('typescript')
const labelsToAdd = [
...(wantPython ? ['Python'] : []),
...(wantTypeScript ? ['TypeScript'] : []),
]
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: labelsToAdd,
})
}