This projects provides a GitHub Action that can be used on pull requests to validate if their title/description contain required text.
- Title Validation: checks if title contains specified substring or regular expression
- Body Validation: checks if PR description contains specified substring or regular expression
Add this configuration to your workflow configuration at .github/workflows
.
name: Pull Request Template Validation
on:
pull_request:
types: [opened, edited, synchronize, labeled, unlabeled]
jobs:
pr-template-validation:
name: Validates if PR title and body matches template
runs-on: ubuntu-latest
# Don't run on PRs labeled as exception
if: ${{ !contains(github.event.*.labels.*.name, 'skip-pr-template-validation') }}
steps:
- name: Validate PR Title & Body
uses: nowNick/pr-template-validator@main
with:
title-contains: 'XYZ-'
body-regex: 'ABC-\d+'
This action can be configured by following inputs:
Expected substring that a PR title should contain
Expected regular expression that a PR title should match to
Expected substring that a PR body should contain
Expected regular expression that a PR body should match to