Skip to content

Kong/pr-template-validator

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

PR Template Validator

GitHub Super-Linter CI Check dist/ CodeQL

This projects provides a GitHub Action that can be used on pull requests to validate if their title/description contain required text.

Features

  • Title Validation: checks if title contains specified substring or regular expression
  • Body Validation: checks if PR description contains specified substring or regular expression

Usage

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+'

Inputs

This action can be configured by following inputs:

title-contains

Expected substring that a PR title should contain

title-regex

Expected regular expression that a PR title should match to

body-contains

Expected substring that a PR body should contain

body-regex

Expected regular expression that a PR body should match to