Reconciler pattern that validates GitHub pull requests and creates Check Runs with the validation results.
What it does:
- Validates PR title follows conventional commit format
- Validates PR description is not empty or too short
- Creates a GitHub Check Run showing pass/fail status
- Uses
statusmanagerfor idempotent check run management
Validation rules and the Details payload come from the shared
prvalidation library. The reconciler concepts used here are
documented in the main examples README;
they cover the StatusManager, the Details payload, the idempotent reconcile loop,
workqueue integration, and error handling.
┌──────────┐ GCP
│ GitHub │ ┌────────────────────────────────────────────────────────────────┐
│ │ │ │
│ PR open │ │ ┌─────────────┐ ┌──────────────────────┐ │
│ PR edit ├────┼─►│github-events├──►│ CloudEvents Broker │ │
│ │ │ │ (webhook) │ │ (filter + enqueue) │ │
│ │ │ └─────────────┘ └──────────┬───────────┘ │
└────▲─────┘ │ │ │
│ │ ▼ │
│ │ ┌──────────────────────┐ │
│ │ │ Workqueue │ │
│ │ │ (rcv + dispatcher) │ │
│ │ └──────────┬───────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌──────────────┐ ┌──────────────────────┐ │
│ │ │ OctoSTS │◄─│ Reconciler │ │
│ │ │ (get token) │ │ (validator) │ │
│ │ └──────────────┘ └──────────┬───────────┘ │
│ │ │ │
└──────────┼───────────────────────────────┘ │
Check Run │ Create/Update Check Run via GitHub API │
└────────────────────────────────────────────────────────────────┘
Flow:
- GitHub sends a webhook when a PR is opened or edited.
github-eventsconverts the webhook into a CloudEvent.- The CloudEvents Broker routes it onto the Workqueue.
- The reconciler validates the PR title and description via
prvalidation.ValidatePR. - It creates or updates the Check Run with pass/fail status using
statusmanager.
github-pr-validator/
└── cmd/reconciler/
├── main.go # Reconciler entry point and PR validation orchestration
└── main_test.go # Unit tests
cd examples
go test ./github-pr-validator/...No GitHub credentials or external services required.