mirror of
https://github.com/numpy/numpy.git
synced 2026-10-28 16:34:42 +08:00
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Co-authored-by: Ralf Gommers <ralf.gommers@gmail.com>
42 lines
1.4 KiB
YAML
42 lines
1.4 KiB
YAML
name: "Pull Request Labeler"
|
|
|
|
on: # zizmor: ignore[dangerous-triggers] safe: no PR-head checkout, no code execution, labels only
|
|
pull_request_target:
|
|
types: [opened]
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
pr-labeler:
|
|
if: github.repository == 'numpy/numpy'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write # to add labels
|
|
contents: read # to read .github/pr-prefix-labeler.json
|
|
steps:
|
|
- name: Label the PR
|
|
continue-on-error: true
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
with:
|
|
script: |
|
|
const {data} = await github.rest.repos.getContent({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
path: '.github/pr-prefix-labeler.json',
|
|
});
|
|
const prefixToLabel = JSON.parse(
|
|
Buffer.from(data.content, data.encoding).toString()
|
|
);
|
|
const title = context.payload.pull_request.title;
|
|
for (const [prefix, label] of Object.entries(prefixToLabel)) {
|
|
if (title.startsWith(prefix)) {
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.pull_request.number,
|
|
labels: [label],
|
|
});
|
|
break;
|
|
}
|
|
}
|