neovim/.github/workflows/labeler.yml

125 lines
3.5 KiB
YAML
Raw Normal View History

name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@main
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
type-scope:
runs-on: ubuntu-latest
needs: ["triage"]
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- 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"]
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
});