forked from openshift/compliance-operator
-
Notifications
You must be signed in to change notification settings - Fork 39
33 lines (29 loc) · 1 KB
/
check-pr-title.yaml
File metadata and controls
33 lines (29 loc) · 1 KB
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
name: "Check PR title"
on:
pull_request_target:
types: [opened, edited, synchronize]
jobs:
check-title:
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Check if the PR title is well dressed
if: >-
github.event.pull_request.user.login != 'renovate[bot]' &&
github.event.pull_request.user.login != 'red-hat-konflux[bot]'
env:
JIRA: '([A-Z]+-[0-9]+, ?)*[A-Z]+-[0-9]+'
TEXT: ': .+'
run: |
# Either conventional or JIRA-nnn prefix followed by ': ' and random text:
REGEX="($JIRA)($TEXT)"
test_regex() { echo -nE "$1" | grep --perl-regexp --line-regexp "$REGEX" ; }
echo "Examples:"
test_regex 'CMP-123: text'
test_regex 'CMP-123, OCPBUGS-12345: text'
if ! test_regex "$PR_TITLE"
then
echo "::error::Please update the PR title so that it follows the convention."
exit 1
fi