1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
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|')"
add-reviewer:
# This job currently doesn't work due to a bug in GitHub CLI.
#
# Issue: https://github.com/cli/cli/issues/4844
# PR that will fix it: https://github.com/cli/cli/pull/4876
#
# The current workaround is to temporarily add "continue-on-error" flag so
# the whole workflow doesn't get flagged as a failure.
runs-on: ubuntu-latest
needs: ["triage", "type-scope"]
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
continue-on-error: true
steps:
- name: Get labels
id: labels
run: echo "::set-output name=labels::$(gh pr view $PR_NUMBER --json labels --jq '.labels.[].name' | tr '\n' '%')"
# The % at the end of the label is a hack to avoid selecting a label that
# is substring of another label. So if there is a label "cinema" then we
# don't accidentally want to interpret that as the label "ci"
- if: contains(steps.labels.outputs.labels, 'api%')
run: gh pr edit $PR_NUMBER --add-reviewer bfredl,gpanders,muniter
- if: contains(steps.labels.outputs.labels, 'ci%')
run: gh pr edit $PR_NUMBER --add-reviewer jamessan
- if: contains(steps.labels.outputs.labels, 'diagnostic%')
run: gh pr edit $PR_NUMBER --add-reviewer gpanders
- if: contains(steps.labels.outputs.labels, 'distribution%')
run: gh pr edit $PR_NUMBER --add-reviewer jamessan
- if: contains(steps.labels.outputs.labels, 'documentation%')
run: gh pr edit $PR_NUMBER --add-reviewer clason
- if: contains(steps.labels.outputs.labels, 'extmarks%')
run: gh pr edit $PR_NUMBER --add-reviewer bfredl
- if: contains(steps.labels.outputs.labels, 'filetype%')
run: gh pr edit $PR_NUMBER --add-reviewer clason,gpanders
- if: contains(steps.labels.outputs.labels, 'gui%')
run: gh pr edit $PR_NUMBER --add-reviewer glacambre,smolck
- if: contains(steps.labels.outputs.labels, 'platform:windows%')
run: gh pr edit $PR_NUMBER --add-reviewer erw7
- if: contains(steps.labels.outputs.labels, 'lsp%')
run: gh pr edit $PR_NUMBER --add-reviewer mfussenegger,mjlbach
- if: contains(steps.labels.outputs.labels, 'terminal%')
run: gh pr edit $PR_NUMBER --add-reviewer erw7
- if: contains(steps.labels.outputs.labels, 'treesitter%')
run: gh pr edit $PR_NUMBER --add-reviewer bfredl,vigoux
- if: contains(steps.labels.outputs.labels, 'typo%')
run: gh pr edit $PR_NUMBER --add-reviewer dundargoc
- if: contains(steps.labels.outputs.labels, 'ui%')
run: gh pr edit $PR_NUMBER --add-reviewer bfredl
- if: contains(steps.labels.outputs.labels, 'vim-patch%')
run: gh pr edit $PR_NUMBER --add-reviewer janlazo,seandewar
|