-
Notifications
You must be signed in to change notification settings - Fork 9
54 lines (54 loc) · 2.41 KB
/
pr-title-check.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
51
52
53
54
name: "Semantic PR Check"
on:
workflow_call:
pull_request:
types: [opened, reopened, synchronize, edited]
jobs:
pr-title-check:
name: "Check PR for semantic title"
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: "Set PR title validity"
id: is-semantic
if: >
startsWith(github.event.pull_request.title, 'feat:')||
startsWith(github.event.pull_request.title, 'fix:') ||
startsWith(github.event.pull_request.title, 'perf:') ||
startsWith(github.event.pull_request.title, 'docs:') ||
startsWith(github.event.pull_request.title, 'test:') ||
startsWith(github.event.pull_request.title, 'refactor:') ||
startsWith(github.event.pull_request.title, 'style:') ||
startsWith(github.event.pull_request.title, 'build:') ||
startsWith(github.event.pull_request.title, 'ci:') ||
startsWith(github.event.pull_request.title, 'chore:') ||
startsWith(github.event.pull_request.title, 'revert:')
run: |
OUTPUT=true
echo "isSemantic=$OUTPUT" >> $GITHUB_OUTPUT
- name: "echo isSemantic"
run: |
echo ${{ steps.is-semantic.outputs.isSemantic }}
- name: "PR title is valid"
if: ${{steps.is-semantic.outputs.isSemantic == 'true'}}
run: |
echo 'Pull request title is valid.'
echo ${{ steps.is-semantic.outputs.isSemantic }}
- name: "PR title is invalid"
if: ${{ steps.is-semantic.outputs.isSemantic != 'true'}}
run: |
echo ${{ steps.is-semantic.outputs.isSemantic }}
echo 'Pull request title, ${{github.event.pull_request.title}} is not valid.'
echo 'title must start with one of:'
echo ' build:,'
echo ' chore:,'
echo ' ci:,'
echo ' docs:,'
echo ' feat:,'
echo ' fix:,'
echo ' perf:,'
echo ' refactor:,'
echo ' revert:,'
echo ' style:,'
echo ' test:'
exit 1