Skip to content

Commit 8c063c7

Browse files
authored
chore: Validate PR title (#297)
1 parent e1bccb7 commit 8c063c7

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

.github/semantic.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Disable validation, and skip status check creation
2+
enabled: true
3+
# Always validate the PR title, and ignore the commits
4+
titleOnly: true
5+
# Always validate all commits, and ignore the PR title
6+
commitsOnly: false
7+
# Always validate the PR title AND all the commits
8+
titleAndCommits: false
9+
# By default types specified in commitizen/conventional-commit-types is used.
10+
# See: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json
11+
# You can override the valid types
12+
types:
13+
- feat
14+
- fix
15+
- docs
16+
- ci
17+
- chore

.github/workflows/pr-title.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Validate PR title"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
main:
12+
name: Validate PR title
13+
runs-on: ubuntu-latest
14+
steps:
15+
# Please look up the latest version from
16+
# https://github.com/amannn/action-semantic-pull-request/releases
17+
- uses: amannn/action-semantic-pull-request@v3.4.6
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
# Configure which types are allowed.
22+
# Default: https://github.com/commitizen/conventional-commit-types
23+
types: |
24+
fix
25+
feat
26+
docs
27+
ci
28+
chore
29+
# Configure which scopes are allowed.
30+
scopes: |
31+
core
32+
ui
33+
# Configure that a scope must always be provided.
34+
requireScope: false
35+
# Configure additional validation for the subject based on a regex.
36+
# This example ensures the subject starts with an uppercase character.
37+
subjectPattern: ^[A-Z].+$
38+
# If `subjectPattern` is configured, you can use this property to override
39+
# the default error message that is shown when the pattern doesn't match.
40+
# The variables `subject` and `title` can be used within the message.
41+
subjectPatternError: |
42+
The subject "{subject}" found in the pull request title "{title}"
43+
didn't match the configured pattern. Please ensure that the subject
44+
starts with an uppercase character.
45+
# For work-in-progress PRs you can typically use draft pull requests
46+
# from Github. However, private repositories on the free plan don't have
47+
# this option and therefore this action allows you to opt-in to using the
48+
# special "[WIP]" prefix to indicate this state. This will avoid the
49+
# validation of the PR title and the pull request checks remain pending.
50+
# Note that a second check will be reported if this is enabled.
51+
wip: true
52+
# When using "Squash and merge" on a PR with only one commit, GitHub
53+
# will suggest using that commit message instead of the PR title for the
54+
# merge commit, and it's easy to commit this by mistake. Enable this option
55+
# to also validate the commit message for one commit PRs.
56+
validateSingleCommit: true

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
@semantic-release/changelog@6.0.0
3030
@semantic-release/git@10.0.0
3131
env:
32-
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)