@@ -27,97 +27,137 @@ request — message, branch, author, and optionally the PR title — against you
2727` cchk.toml ` , and reports the result in the job summary, as annotations on the
2828diff and, if you want, as a PR comment.
2929
30- ## Start with one check
30+ ## Usage
31+
32+ Three examples. Each is a complete workflow, e.g.
33+ ` .github/workflows/commit-check.yml ` ; start with the one you need.
3134
32- Each of these is a complete workflow. Pick one, then turn on more checks when
33- you need them.
35+ ### 1. Commit messages and branch name
3436
35- ** Pull request title only.** On a repository that squash-merges, the title
36- becomes the commit on ` main ` , so it is the one message worth checking. With
37- GitHub's default squash message, a pull request of a single commit lands that
38- commit's message instead; set the squash commit message to "Pull request
39- title" in the repository settings to make the title the one that lands:
37+ Both are checked by default, against
38+ [ Conventional Commits] ( https://www.conventionalcommits.org/ ) and
39+ [ Conventional Branch] ( https://conventionalbranch.org/ ) , so the action needs no
40+ inputs:
4041
4142``` yaml
42- name : PR Title
43+ name : Commit Check
4344
4445on :
4546 pull_request :
46- types : [opened, edited, synchronize, reopened]
4747
4848jobs :
49- pr-title :
49+ commit-check :
5050 runs-on : ubuntu-latest
5151 steps :
5252 - uses : actions/checkout@v7
53- - uses : commit-check/commit-check-action@v2
5453 with :
55- message : false
56- branch : false
57- pr-title : true
54+ fetch-depth : 0 # recommended: read the PR's commits from the clone
55+ - uses : commit-check/commit-check-action@v2
5856` ` `
5957
60- **Branch name only**, against [Conventional Branch](https://conventionalbranch.org/):
58+ > [!NOTE]
59+ > ` fetch-depth: 0` is recommended, not required. A shallow clone holds only
60+ > GitHub's merge commit, so the action lists the pull request's commits
61+ > through the API — up to 250, with `pull-requests: read` — and fetches the
62+ > head commit for the author checks. If the commits cannot be listed, it warns
63+ > and checks HEAD alone; if the head commit cannot be fetched, it warns and
64+ > skips the author checks.
65+
66+ # ## 2. Pull request title
67+
68+ On a repository that squash-merges, the title becomes the commit on `main`, so
69+ it is the one message worth checking. With GitHub's default squash message, a
70+ pull request of a single commit lands that commit's message instead; set the
71+ squash commit message to "Pull request title" in the repository settings to
72+ make the title the one that lands :
6173
6274` ` ` yaml
63- name : Branch Name
75+ name: PR Title
6476
6577on:
6678 pull_request:
79+ types: [opened, edited, synchronize, reopened]
6780
6881jobs:
69- branch-name :
82+ pr-title :
7083 runs-on: ubuntu-latest
7184 steps:
7285 - uses: actions/checkout@v7
7386 - uses: commit-check/commit-check-action@v2
7487 with:
7588 message: false
89+ branch: false
90+ pr-title: true
7691` ` `
7792
78- Both read the repository's ` cchk.toml` if there is one, so a custom type list
79- or an extra allowed branch name works without changing the workflow.
93+ # ## 3. Job summary
8094
81- # # Usage
95+ Every run writes its report to the job summary; `job-summary` is on by
96+ default. A failing run opens with a count and a table of only what failed —
97+ each rule ID links to its documentation, each commit to itself — with the full
98+ tree one click away :
8299
83- Add a workflow, e.g. `.github/workflows/commit-check.yml` :
100+ > **Commit Check**
101+ >
102+ > ❌ **2 of 4 checks failed**
103+ >
104+ > | Scope | Checked value | Failed checks |
105+ > |---|---|---|
106+ > | [Commit 2/2 (5584f46)](https://github.com/acme/widgets/commit/5584f462cc3c947b2ba8d3d1a5735571803ee159) | `bad msg` | [CC001 message](https://commit-check.com/rules/#cc001) |
107+ > | Branch | `Feature/Add-Login` | [CC201 branch](https://commit-check.com/rules/#cc201) |
108+ >
109+ > <details>
110+ > <summary>Show all 4 checks</summary>
111+ >
112+ > ```text
113+ > Commit message
114+ > ✔ PR title (feat: add login page)
115+ > ✔ Commit 1/2 (d87faca) (feat: add login page)
116+ > ✖ Commit 2/2 (5584f46) (1 failure)
117+ > CC001 message
118+ > value: bad msg
119+ > The commit message should follow Conventional Commits.
120+ > Suggest: Use <type>(<scope>): <description>
121+ > Branch
122+ > ✖ Branch (1 failure)
123+ > CC201 branch
124+ > value: Feature/Add-Login
125+ > The branch should follow Conventional Branch.
126+ > Suggest: Rename the branch to "feature/Add-Login" (git branch -m feature/Add-Login)
127+ > Fix: feature/Add-Login
128+ > ```
129+ >
130+ > </details>
131+ >
132+ > _commit-check <version> · [Rules reference](https://commit-check.com/rules/)_
84133
85- ` ` ` yaml
86- name: Commit Check
134+ The rest follow the same layout :
87135
88- on:
89- pull_request:
90- branches: 'main'
136+ - **Passed:** one line, `✅ All 3 checks passed`, with the tree folded away.
137+ - **Warned:** a rule under `warn` gets its own ⚠ row and counts as passed.
138+ - **Skipped:** a run where nothing was validated — typically a bot listed in
139+ ` ignore_authors` — reads `⊘`, never `✔`.
91140
92- jobs:
93- commit-check:
94- runs-on: ubuntu-latest
95- permissions: # use permissions because use of pr-comments
141+ The step log prints the same tree, plus one annotation per finding on the
142+ Files changed tab. To post the same report on the pull request, edited in
143+ place on later runs, add `pr-comments : true` and grant the job
144+ `pull-requests : write`:
145+
146+ ` ` ` yaml
147+ permissions:
96148 contents: read
97149 pull-requests: write
98150 steps:
99151 - uses: actions/checkout@v7
100- with:
101- # Recommended: the action then reads the PR's commits from the clone.
102- # With the default fetch-depth: 1 it asks the GitHub API instead.
103- fetch-depth: 0
104152 - uses: commit-check/commit-check-action@v2
105153 with:
106- # Commit messages and the branch name are checked by default;
107- # see Inputs for the rest.
108154 pr-comments: true
109155` ` `
110156
111- > [!NOTE]
112- > `fetch-depth: 0` is recommended, not required. A shallow clone holds only
113- > GitHub's merge commit, so the action lists the pull request's commits
114- > through the API — up to 250, with `pull-requests: read` — and fetches the
115- > head commit for the author checks. If the commits cannot be listed, it warns
116- > and checks HEAD alone; if the head commit cannot be fetched, it warns and
117- > skips the author checks.
118-
119- Runs on `ubuntu-latest`, `macos-latest` and `windows-latest`. Self-hosted
120- runners need a few tools — see [Good to know](#good-to-know).
157+ All three read the repository's `cchk.toml` if there is one, so a custom type
158+ list or an extra allowed branch name works without changing the workflow. The
159+ action runs on `ubuntu-latest`, `macos-latest` and `windows-latest`;
160+ self-hosted runners need a few tools — see [Good to know](#good-to-know).
121161
122162# # Inputs
123163
@@ -156,57 +196,6 @@ Priority: inputs > environment variables > config file > defaults. A rule
156196listed under the config's top-level `warn` is reported in full but never fails
157197the run. Every key : [configuration reference](https://commit-check.com/configuration/).
158198
159- # # What it looks like
160-
161- A failing run opens with a count and a table of only what failed — each rule ID
162- links to its documentation, each commit to itself — with the full tree one
163- click away :
164-
165- > **Commit Check**
166- >
167- > ❌ **2 of 4 checks failed**
168- >
169- > | Scope | Checked value | Failed checks |
170- > |---|---|---|
171- > | [Commit 2/2 (5584f46)](https://github.com/acme/widgets/commit/5584f462cc3c947b2ba8d3d1a5735571803ee159) | `bad msg` | [CC001 message](https://commit-check.com/rules/#cc001) |
172- > | Branch | `Feature/Add-Login` | [CC201 branch](https://commit-check.com/rules/#cc201) |
173- >
174- > <details>
175- > <summary>Show all 4 checks</summary>
176- >
177- > ```text
178- > Commit message
179- > ✔ PR title (feat: add login page)
180- > ✔ Commit 1/2 (d87faca) (feat: add login page)
181- > ✖ Commit 2/2 (5584f46) (1 failure)
182- > CC001 message
183- > value: bad msg
184- > The commit message should follow Conventional Commits.
185- > Suggest: Use <type>(<scope>): <description>
186- > Branch
187- > ✖ Branch (1 failure)
188- > CC201 branch
189- > value: Feature/Add-Login
190- > The branch should follow Conventional Branch.
191- > Suggest: Rename the branch to "feature/Add-Login" (git branch -m feature/Add-Login)
192- > Fix: feature/Add-Login
193- > ```
194- >
195- > </details>
196- >
197- > _commit-check <version> · [Rules reference](https://commit-check.com/rules/)_
198-
199- The rest follow the same layout :
200-
201- - **Passed:** one line, `✅ All 3 checks passed`, with the tree folded away.
202- - **Warned:** a rule under `warn` gets its own ⚠ row and counts as passed.
203- - **Skipped:** a run where nothing was validated — typically a bot listed in
204- ` ignore_authors` — reads `⊘`, never `✔`.
205-
206- The step log prints the same tree, plus one annotation per finding on the
207- Files changed tab. With `pr-comments : true` the same report is posted to the
208- pull request, and later runs edit that one comment instead of adding more.
209-
210199# # Outputs
211200
212201# ## `result`
@@ -332,8 +321,8 @@ repositories) or run the action on `pull_request_target` — both are covered in
332321
333322Dependabot pull requests are not forks, but their `pull_request` runs also get
334323a read-only token by default. The `pull-requests : write` grant in the
335- [usage example](#usage ) is honoured for them; without it the action logs a
336- ` ::warning::` on the 403 and leaves the report in the job summary. Adding
324+ [job summary example](#3-job-summary ) is honoured for them; without it the
325+ action logs a `::warning::` on the 403 and leaves the report in the job summary. Adding
337326` dependabot[bot]` to `ignore_authors` skips those pull requests altogether.
338327
339328</details>
0 commit comments