Skip to content

AbsaOSS/check-pr-requirements

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Check PR Requirements

A configurable GitHub Action that validates pull request properties against a set of requirements. Each check can be independently enabled/disabled, making it easy to enforce only the rules that matter for your project.

Available Checks

Check Default Description
check-title true PR title matches an allowed format: Conventional Commits, issue-number prefix (#123: Title), or custom regex
check-description true PR body meets minimum length and contains required sections
check-issue-reference true PR references a GitHub issue (#123, Fixes #123, issue URL) or Azure Boards work item (AB#12345)
check-release-notes false PR body contains release notes section (uses AbsaOSS/release-notes-presence-check)
check-branch-name false Source branch follows naming convention
check-pr-size false PR does not exceed maximum file change count
check-label false PR has required labels
check-target-branch false PR targets an allowed branch

Usage

name: Check PR Requirements

on:
  pull_request:
    types: [opened, synchronize, reopened, edited, labeled, unlabeled]

permissions:
  contents: read
  pull-requests: read

jobs:
  check-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Check PR requirements
        uses: AbsaOSS/check-pr-requirements@v0.1.0
        with:
          pr-title: ${{ github.event.pull_request.title }}
          pr-body: ${{ github.event.pull_request.body }}
          pr-branch: ${{ github.event.pull_request.head.ref }}
          pr-number: ${{ github.event.pull_request.number }}
          target-branch: ${{ github.event.pull_request.base.ref }}
          files-changed: ${{ github.event.pull_request.changed_files }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          check-title: "true"
          check-description: "true"
          check-issue-reference: "true"
          check-release-notes: "true"

Minimal Configuration

Only check what you need:

- uses: AbsaOSS/check-pr-requirements@v0.1.0
  with:
    pr-title: ${{ github.event.pull_request.title }}
    check-title: "true"
    check-description: "false"
    check-issue-reference: "false"

Inputs

PR Data

Input Required Description
pr-title Yes Pull request title
pr-body No Pull request body/description
pr-branch No Source branch name
pr-number No Pull request number
target-branch No Target branch name
files-changed No Number of files changed
labels No Comma-separated list of PR labels
github-token No GitHub token (required for release notes check)

Check Configuration

Input Default Description
title-formats conventional Comma-separated allowed title formats, pass if any matches: conventional, issue-number (#123: Title or 123 - Title), custom
title-types feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert Allowed conventional commit types (conventional format)
title-scopes (empty = any) Allowed scopes (conventional format), e.g. api,ui,auth
title-pattern (empty) Regex the title must match (custom format), e.g. ^\[[A-Z]+-[0-9]+\] .+ (matches [PROJ-123] Title)
description-min-length 20 Minimum description character count
description-required-sections (empty = none) Comma-separated headings that must appear in the PR body, e.g. ## Overview,## Release Notes
issue-reference-require-keyword false Only keyword references count (Fixes #123, Closes AB#12345); bare #123 / AB#123 / URLs are rejected
branch-pattern `^(feature bugfix
branch-require-ticket false Require ticket number after the branch prefix (feature/123-user-login)
max-files-changed 50 Maximum files changed
required-labels (empty = any label) Required label names, e.g. bug,enhancement
allowed-target-branches main,master Allowed target branches; glob patterns supported (main,support/*)
release-notes-tag ## [Rr]elease [Nn]otes Release notes section header pattern
release-notes-skip-labels no RN Labels that skip release notes check
release-notes-skip-placeholders TBD Placeholders indicating missing notes

Outputs

Output Description
result pass or fail
pass-count Number of checks passed
fail-count Number of checks failed
total-count Total checks executed

Adding a New Check

  1. Create checks/my_check.sh — reads INPUT_* env vars, prints pass or fail: reason, exits 0 or 1
  2. Add entry to REGISTRY array in check.sh
  3. Add inputs to action.yml (toggle + config)
  4. Add env mapping in action.yml composite step
  5. Create tests/test_my_check.sh
  6. Add test file to TEST_FILES array in tests/run_tests.sh

License

Apache License 2.0 — see LICENSE.

About

Action to check required parameters of the PR

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages