2021-05-18 00:37:18 -07:00
|
|
|
name: "Pull Request Labeler"
|
|
|
|
on:
|
2021-07-28 02:30:08 -07:00
|
|
|
pull_request_target:
|
2022-01-07 05:32:14 -07:00
|
|
|
types: [opened]
|
2021-05-18 00:37:18 -07:00
|
|
|
jobs:
|
2022-01-08 05:51:42 -07:00
|
|
|
|
2021-05-18 00:37:18 -07:00
|
|
|
triage:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
pull-requests: write
|
|
|
|
steps:
|
|
|
|
- uses: actions/labeler@main
|
|
|
|
with:
|
|
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
2022-01-08 05:51:42 -07:00
|
|
|
|
2021-09-30 08:08:36 -07:00
|
|
|
type-scope:
|
|
|
|
runs-on: ubuntu-latest
|
2022-01-07 05:32:14 -07:00
|
|
|
needs: ["triage"]
|
2021-09-30 08:08:36 -07:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2021-10-15 07:08:12 -07:00
|
|
|
GH_REPO: ${{ github.repository }}
|
|
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
2021-09-30 08:08:36 -07:00
|
|
|
steps:
|
2022-01-08 05:51:42 -07:00
|
|
|
- name: "Extract commit type and add as label"
|
|
|
|
continue-on-error: true
|
|
|
|
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')"
|
|
|
|
- name: "Extract commit scope and add as label"
|
|
|
|
continue-on-error: true
|
|
|
|
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')"
|
2022-02-07 11:43:09 -07:00
|
|
|
|
|
|
|
add-reviewer:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: ["triage", "type-scope"]
|
2022-02-08 01:26:15 -07:00
|
|
|
permissions:
|
|
|
|
pull-requests: write
|
2022-02-07 11:43:09 -07:00
|
|
|
steps:
|
|
|
|
- uses: actions/github-script@v5
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const reviewers = []
|
|
|
|
|
|
|
|
const { data: { labels } } = await github.rest.pulls.get({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
pull_number: context.issue.number
|
|
|
|
})
|
|
|
|
const label_names = labels.map(label => label.name)
|
|
|
|
|
2022-02-09 02:12:51 -07:00
|
|
|
if (label_names.includes('api')) {
|
|
|
|
reviewers.push("bfredl")
|
|
|
|
reviewers.push("gpanders")
|
|
|
|
reviewers.push("muniter")
|
|
|
|
}
|
|
|
|
|
2022-02-07 11:43:09 -07:00
|
|
|
if (label_names.includes('ci')) {
|
|
|
|
reviewers.push("jamessan")
|
|
|
|
}
|
|
|
|
|
2022-02-09 02:12:51 -07:00
|
|
|
if (label_names.includes('diagnostic')) {
|
|
|
|
reviewers.push("gpanders")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('distribution')) {
|
|
|
|
reviewers.push("jamessan")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('documentation')) {
|
|
|
|
reviewers.push("clason")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('extmarks')) {
|
|
|
|
reviewers.push("bfredl")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('filetype')) {
|
|
|
|
reviewers.push("clason")
|
|
|
|
reviewers.push("gpanders")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('gui')) {
|
|
|
|
reviewers.push("glacambre")
|
|
|
|
reviewers.push("smolck")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('lsp')) {
|
|
|
|
reviewers.push("mfussenegger")
|
|
|
|
reviewers.push("mjlbach")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('treesitter')) {
|
|
|
|
reviewers.push("bfredl")
|
|
|
|
reviewers.push("vigoux")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('typo')) {
|
|
|
|
reviewers.push("dundargoc")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label_names.includes('ui')) {
|
|
|
|
reviewers.push("bfredl")
|
|
|
|
}
|
|
|
|
|
2022-02-07 11:43:09 -07:00
|
|
|
if (label_names.includes('vim-patch')) {
|
2022-02-09 02:12:51 -07:00
|
|
|
reviewers.push("janlazo")
|
2022-02-07 11:43:09 -07:00
|
|
|
reviewers.push("seandewar")
|
2022-02-09 02:12:51 -07:00
|
|
|
reviewers.push("zeertzjq")
|
2022-02-07 11:43:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const index = reviewers.indexOf(context.actor);
|
|
|
|
if (index > -1) {
|
|
|
|
reviewers.splice(index, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
github.rest.pulls.requestReviewers({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
pull_number: context.issue.number,
|
|
|
|
reviewers: reviewers
|
|
|
|
});
|