Stop Copy-Pasting Conventional Commits Rules: Auto-Fix Your Commits in CI
说明与用途
使用 GitHub Action 自动修复 CI 中的提交和 PR 消息,支持 Conventional Commits 规则、单体仓库按包路由,并生成 SARIF 供 GitHub 安全使用。
问题
Conventional Commits checks fail in CI and fix commits are themselves incorrectly formatted, leading to long PR titles, missing sections, and inconsistent rules across monorepo packages.
结果
Automated enforcement and correction of Conventional Commits rules in CI, eliminating manual fixes and configuration duplication in monorepos, while providing SARIF output for security dashboards.
工作流
- Configure a .github/pr-conventional.yml with desired rules or use an example file (strict.yml, relaxed.yml, monorepo.yml, chinese-team.yml).
- Add a GitHub Actions workflow that checks out the repo and runs the RedSamerai/pr-conventional action (e.g., RedSamerai/[email protected]).
- On each push or PR, the action scans all new commits (up to 20) and the PR title/body. It amends commit messages, appends missing sections, truncates long titles, and re‑validates.
- If the run succeeds, a pr-conventional.sarif file is produced and can be uploaded to GitHub Security via upload-sarif.
证据
I wanted one that actually fixes it.
It checks every new commit in the push (before..after, up to 20), the PR title, and the PR body.
Monorepo per-package routing
Every run writes pr-conventional.sarif. Pipe it into upload-sarif and findings land in the GitHub Security tab.
- 记录日期: 2026-10-13T13:41:04.062Z