Skip to content
26 changes: 26 additions & 0 deletions .github/actions/check-pr-title-format/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Validate PR title
description: "Validate pull request title against a regex"
inputs:
Comment thread
damientobin1 marked this conversation as resolved.
title:
description: "Pull request title"
required: true
runs:
using: "composite"
steps:
- name: "Validate PR title"
shell: bash
Comment thread
damientobin1 marked this conversation as resolved.
env:
TITLE: ${{ inputs.title }}
run: |
title="$TITLE"
pattern='^CCM-[0-9]+: .+$'
message='PR title must match: CCM-1234: Some Text'

echo "PR title: $title"

if printf '%s\n' "$title" | grep -Eq -- "$pattern"; then
echo "PR title is valid"
else
echo "::error::$message"
exit 1
fi