-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 1.53 KB
/
lint-PR-title.yml
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
name: Lint Pull Request Title
on:
pull_request:
types:
- opened
- edited
- reopened
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.event.pull_request.title }}
regex: '(?:add|update|task|chore|feat|fix|refactor)\([a-z-A-Z]+\):\s.+'
- uses: actions-ecosystem/action-create-comment@v1
if: ${{ steps.regex-match.outputs.match == '' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
:warning: The title of this PR is invalid.
Please make the title match the regex `(?:add|update|task|chore|feat|fix|refactor)\([a-z-A-Z]+\):\s.+`.
e.g.) `add(cli): enable --verbose flag`, `fix(api): avoid unexpected error in handler`
- name: Add invalid PR title label if regex is not matching
if: ${{ steps.regex-match.outputs.match == '' }}
uses: buildsville/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
invalid PR title
type: add
- name: Remove label if regex is matching
if: ${{ steps.regex-match.outputs.match != '' }}
uses: buildsville/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: |
invalid PR title
type: remove
- run: exit 1
if: ${{ steps.regex-match.outputs.match == '' }}