Skip to content

Commit 781a040

Browse files
shenxianpengclaude
andcommitted
docs(readme): explain fetch-depth, runner requirements, Dependabot, and the alternatives
The usage snippet's fetch-depth comment did not say what a shallow clone costs: the action falls back to GitHub's merge commit, whose subject passes the default rules, so every PR looks green and author checks are skipped. Spell that out in the comment and a WARNING callout, with the exact annotation the run carries. Add a "Runner requirements" section (Python 3.10+, the gh CLI for the attestation check, PyPI and api.github.com access, git; which wheels are and are not attested; no input skips verification) — action.yml now points self-hosted operators here. Add the "Action, pre-commit hook, or GitHub App" comparison so evaluators can pick, and note under pr-comments that Dependabot pull requests are skipped like forks because GitHub runs their pull_request workflows with a read-only token. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
1 parent 3d187db commit 781a040

1 file changed

Lines changed: 57 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A GitHub Action for checking commit message formatting, branch naming, committer
2424
## Table of Contents
2525

2626
* [Usage](#usage)
27+
* [Action, pre-commit hook, or GitHub App — which to use?](#action-pre-commit-hook-or-github-app--which-to-use)
2728
* [Optional Inputs](#optional-inputs)
2829
* [GitHub Action Job Summary](#github-action-job-summary)
2930
* [GitHub Pull Request Comments](#github-pull-request-comments)
@@ -52,7 +53,10 @@ jobs:
5253
steps:
5354
- uses: actions/checkout@v7
5455
with:
55-
fetch-depth: 0 # With a shallow clone only HEAD, the merge commit, is checked
56+
# Required. With the default fetch-depth: 1 the clone holds only GitHub's
57+
# merge commit: the PR's own commits cannot be listed, author checks are
58+
# skipped, and the action warns and falls back to checking HEAD alone.
59+
fetch-depth: 0
5660
- uses: commit-check/commit-check-action@v2
5761
with:
5862
message: true
@@ -63,9 +67,52 @@ jobs:
6367
pr-comments: true
6468
```
6569
70+
> [!WARNING]
71+
> Without `fetch-depth: 0` the action still runs, but it cannot see the pull
72+
> request's commits. It posts `::warning title=commit-check::Could not list the
73+
> pull request's commits (is actions/checkout using fetch-depth: 0?); only HEAD
74+
> was checked` and checks only the synthetic merge commit — whose subject
75+
> `Merge <sha> into <sha>` passes the default rules — so a shallow clone makes
76+
> every PR look green. Author checks are skipped (`⊘`) for the same reason. On
77+
> `pull_request_target`, also check out `refs/pull/<number>/merge`.
78+
6679
> [!NOTE]
6780
> This action supports running on Linux, macOS, and Windows (`ubuntu-latest`, `macos-latest`, `windows-latest`).
6881

82+
### Runner requirements
83+
84+
The action is a composite step and uses what the runner already has:
85+
86+
- **Python 3.10 or newer** on `PATH` (`python3`, or `python` on Windows). No
87+
`setup-python` step is needed on GitHub-hosted runners. Everything the action
88+
installs goes under `$RUNNER_TEMP`, never into your checkout.
89+
- **`gh` CLI** — used to verify the build-provenance attestation of the
90+
`commit-check` wheel before installing it. Present on GitHub-hosted images;
91+
install it on self-hosted runners or the step fails with `gh CLI not found`.
92+
Only the `commit-check` wheel is attested; PyGithub and the transitive
93+
dependencies are pinned by `requirements.txt` but not verified.
94+
- **Network access to PyPI and `api.github.com`** — the pinned wheels are
95+
downloaded once per run and the attestation is fetched from GitHub.
96+
- **`git`** on `PATH`, and a checkout with `fetch-depth: 0` (see above).
97+
98+
There is currently no input to skip attestation verification.
99+
100+
## Action, pre-commit hook, or GitHub App — which to use?
101+
102+
All three run the same `commit-check` engine against the same
103+
`commit-check.toml` / `cchk.toml`; they differ in where they run and what they
104+
can see.
105+
106+
| | GitHub Action (this repo) | [pre-commit hook](https://github.com/commit-check/commit-check#use-with-pre-commit) | [Commit Check GitHub App](https://github.com/marketplace/commit-check) |
107+
|---|---|---|---|
108+
| **Where it runs** | In your workflow, on the runner, after the push | On the contributor's machine, at `git commit` / `git push` | Hosted by commit-check; installed on the repository, no workflow file |
109+
| **What it checks** | Every PR commit, the PR title, branch and author; renders a job summary, annotations, a PR comment and the `result` / `report` outputs | Message (`commit-msg` stage), branch, author; tag, force-push and files (`pre-push`) — one commit at a time, before it exists | The pull request's commits, title and branch, reported on the pull request |
110+
| **When to pick it** | You want enforcement in CI that a contributor cannot skip, per-rule outputs for later steps, or you run on GitHub Enterprise Server / need `CCHK_*` overrides | You want the fastest feedback and to stop bad commits before they are pushed; pair it with the Action, since hooks are opt-in | You want zero YAML and no Actions minutes; fork PRs get comments without the [two-workflow pattern](docs/fork-pr-comments.md) |
111+
112+
Most teams pair the pre-commit hook (fast, local) with the Action (enforced):
113+
the hook catches a bad message before it is pushed, and the Action is why CI
114+
fails when a contributor did not install the hook.
115+
69116
## Used By
70117

71118
<p align="center">
@@ -137,6 +184,15 @@ jobs:
137184
> [docs/fork-pr-comments.md](docs/fork-pr-comments.md) for details on how to enable
138185
> this feature for fork contributions.
139186
>
187+
> **Dependabot pull requests** are skipped the same way. GitHub runs
188+
> Dependabot-triggered `pull_request` workflows with a read-only token even
189+
> when the workflow requests `pull-requests: write`, so the permission is not
190+
> the problem: the action logs a `::warning::`, leaves the report in the job
191+
> summary, and the step still exits by the checks' result. To comment on them
192+
> too, use the [two-workflow pattern](docs/fork-pr-comments.md), or run on
193+
> `pull_request_target` for Dependabot only. Adding `dependabot[bot]` to
194+
> `ignore_authors` skips the checks for those PRs altogether.
195+
>
140196
> Note: write-access to pull-requests requires the `pull-requests: write` permission.
141197
> See [usage example](#usage).
142198

0 commit comments

Comments
 (0)