For PR names & also when names are changes right before the merge -> so to say the new commit msg that will go to main.
Something like the following, but better & not for semver:
name: PR Title Semver Check
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
check-semver-title:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get PR title
id: pr_title
run: |
PR_TITLE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
| jq -r .title)
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
- name: Check if PR title matches Semver pattern
run: |
echo "PR Title: $PR_TITLE"
if [[ ! "$PR_TITLE" =~ ^(v[0-9]+\.[0-9]+\.[0-9]+|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "Error: PR title does not follow Semver format."
exit 1
fi
For PR names & also when names are changes right before the merge -> so to say the new commit msg that will go to
main.Something like the following, but better & not for semver: