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