Skip to content

Commit eb719f6

Browse files
committed
CCM-15317: Adding New PR Enforcement Action
1 parent aa7d19f commit eb719f6

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/actions/check-pr-title-format/action.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@ runs:
2424
echo "PR title: $title"
2525
echo "Required pattern: $pattern"
2626
27-
if [[ "$title" =~ $pattern ]]; then
27+
if [ -z "$pattern" ]; then
28+
echo "::error::Input 'pattern' must be a non-empty regular expression"
29+
exit 1
30+
fi
31+
if printf '%s\n' "$title" | grep -Eq -- "$pattern"; then
2832
echo "PR title is valid"
2933
else
30-
echo "::error::$message"
34+
status=$?
35+
case "$status" in
36+
1)
37+
echo "::error::$message"
38+
;;
39+
2)
40+
echo "::error::Input 'pattern' is not a valid regular expression: $pattern"
41+
;;
42+
*)
43+
echo "::error::Unexpected error while validating PR title"
44+
;;
45+
esac
3146
exit 1
3247
fi

0 commit comments

Comments
 (0)