Skip to content

Commit 20892fc

Browse files
committed
ci: validate pull request titles
1 parent 8b74db0 commit 20892fc

3 files changed

Lines changed: 53 additions & 4 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: chore
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
permissions: {}
11+
12+
jobs:
13+
semantic-pr:
14+
permissions:
15+
contents: read
16+
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
17+
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
18+
if: github.repository == 'npmx-dev/npmx.dev'
19+
runs-on: ubuntu-latest
20+
name: semantic-pr
21+
steps:
22+
- name: Validate PR title
23+
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
24+
with:
25+
scopes: |
26+
docs
27+
i18n
28+
deps
29+
subjectPattern: ^(?![A-Z]).+$
30+
subjectPatternError: |
31+
The subject "{subject}" found in the pull request title "{title}"
32+
didn't match the configured pattern. Please ensure that the subject
33+
doesn't start with an uppercase character.
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CONTRIBUTING.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,27 @@ Make sure to read about [Playwright best practices](https://playwright.dev/docs/
365365
4. ensure CI checks pass (lint, type check, tests)
366366
5. request review from maintainers
367367

368-
### Commit messages
368+
### Commit messages and PR titles
369369

370-
Write clear, concise commit messages that explain the "why" behind changes:
370+
Write clear, concise PR titles that explain the "why" behind changes.
371+
372+
We use [Conventional Commits](https://www.conventionalcommits.org/). Since we squash on merge, the PR title becomes the commit message in `main`, so it's important to get it right.
373+
374+
Format: `type(scope): description`
375+
376+
**Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
377+
378+
**Scopes (optional):** `docs`, `i18n`, `deps`
379+
380+
**Examples:**
371381

372382
- `fix: resolve search pagination issue`
373383
- `feat: add package version comparison`
374-
- `docs: update installation instructions`
384+
- `fix(i18n): update French translations`
385+
- `chore(deps): update vite to v6`
386+
387+
> [!NOTE]
388+
> The subject must start with a lowercase letter. Individual commit messages within your PR don't need to follow this format since they'll be squashed.
375389
376390
## Pre-commit hooks
377391

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"*.{js,ts,mjs,cjs,vue}": [
100100
"vite lint --fix"
101101
],
102-
"*.{js,ts,mjs,cjs,vue,json,md,html,css}": [
102+
"*.{js,ts,mjs,cjs,vue,json,yml,md,html,css}": [
103103
"vite fmt"
104104
]
105105
},

0 commit comments

Comments
 (0)