A simple, configurable GitHub Action to validate pull request rules. Built with Rust for reliability and performance.
- ✅ PR Title Validation - Enforce title patterns (e.g., Conventional Commits) and length constraints
- ✅ Required Labels - Ensure PRs have specific labels before merging
- ✅ GitHub Annotations - Clear error messages directly in PR checks
- ✅ Zero Configuration - Works out of the box with sensible defaults
- ✅ Fast & Reliable - Built with Rust, runs in seconds
Create .github/workflows/pr-check-ci.yml:
name: PR Check
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled, edited]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: PR Checker
uses: itscheems/[email protected]
with:
config: .github/pr-checker.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Create .github/pr-checker.yml.
If you don't create this file, the default configuration will be loaded from https://github.com/itscheems/pr-checker/blob/main/pr-checker.yml.
title:
pattern: "^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert)(\\([^)]+\\))?:|^Bump .+"
min_length: 10
labels:
required: []That's it! The Action will now validate all PRs against your rules.
title:
# Regex pattern to match (optional)
pattern: "^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert)(\\([^)]+\\))?:|^Bump .+"
# Minimum length (optional)
min_length: 10
# Maximum length (optional)
max_length: 100labels:
# List of required labels (optional)
required:
- "kind/bug"
- "priority/high"title:
pattern: "^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert)(\\([^)]+\\))?:|^Bump .+"
min_length: 10
max_length: 100
labels:
required:
- "kind/bug"- The Action reads the PR event from
GITHUB_EVENT_PATH - Fetches PR details via GitHub REST API
- Validates against configured rules
- Outputs GitHub annotations for any violations
- Exits with code
1if validation fails,0if all checks pass
| Code | Meaning |
|---|---|
| 0 | All checks passed |
| 1 | Validation failed |
| 2 | Configuration error |
| 3 | GitHub API error |
| 10 | Internal error |
title:
pattern: "^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert)(\\([^)]+\\))?:|^Bump .+"
min_length: 10Valid titles:
feat: add user authenticationfix: resolve memory leakdocs: update API documentation
Invalid titles:
add user authentication(missing prefix)feat: fix(too short)
labels:
required:
- "kind/bug"
- "priority/high"PRs must have both kind/bug and priority/high labels.
| Input | Description | Required | Default |
|---|---|---|---|
config |
Path to config file | No | .github/pr-checker.yml |
| Variable | Description | Required |
|---|---|---|
GITHUB_TOKEN |
GitHub token for API access | Yes |
GITHUB_EVENT_PATH |
Path to GitHub event JSON | Yes (auto-set by GitHub) |
cargo build --releasecargo testdocker build -t pr-checker .export GITHUB_TOKEN=your_token
export GITHUB_EVENT_PATH=/path/to/event.json
cargo run -- --config .github/pr-checker.ymlContributions are welcome! Please feel free to submit a Pull Request.
Licensed under the Apache License, Version 2.0. See LICENSE for details.
itscheems