Uh oh!
There was an error while loading. Please reload this page.
ci: lint pull request titles against the conventional preset - #5
Merged
Conversation
The commit-msg hook only guards local commits; a squash merge takes its subject from the PR title, which nothing validated.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
commit-msghook added in #3 only guards commits made locally. A squash merge takes its subject from the PR title, which nothing validated — so a non-conventional title could still land ondevelopment.This adds a workflow that runs the PR title through commitlint's conventional preset, the same linter and preset the local hook uses.
Notes on the implementation
Self-contained by necessity.
developmenthas neither commitlint norcommitlint.config.js— both arrive in #3, which is still open. A job that ranpnpm install && pnpm exec commitlintwould therefore fail on this PR and stay broken until #3 merged. Instead the job resolves commitlint throughpnpm dlxwith an explicit--extends, so it needs no checkout, no install and no repo files. It works today and in either merge order relative to #3.types: [opened, edited, reopened].editedis the one that matters: without it, correcting a rejected title would not re-run the check.ci.yml's defaultpull_requesttypes excludeedited, which is why this is a separate workflow rather than a job there.The title is passed via
env:, not interpolated intorun:. A PR title is attacker-controlled text;${{ ... }}inline in a shell would allow command execution on the runner. Probed with a title containing"; echo PWNED; #— nothing executed.No third-party action.
amannn/action-semantic-pull-requestis the common choice, but it maintains its own list of allowed types, which would drift fromcommitlint.config.js.Verification
Ran the exact command against a tree with no
commitlint.config.js, matching what CI sees:ci: add pr title lint job→ exit 0added some stuff→ exit 1,type may not be emptyThis PR's own title is checked by the workflow it adds, so a green check here is the end-to-end test.