Skip to content

Commit c2d6f38

Browse files
feat: Fast-Forward upstream changes
1 parent 4256ef5 commit c2d6f38

4 files changed

Lines changed: 4201 additions & 3054 deletions

File tree

README.md

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ See [Conventional Commits](https://www.conventionalcommits.org/) for more exampl
1919

2020
1. If your goal is to create squashed commits that will be used for automated releases, you'll want to configure your GitHub repository to [use the squash & merge strategy](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/configuring-commit-squashing-for-pull-requests) and tick the option "Default to PR title for squash merge commits".
2121
2. [Add the action](https://docs.github.com/en/actions/quickstart) with the following configuration:
22-
2322
```yml
2423
name: "Lint PR"
2524

@@ -29,6 +28,7 @@ on:
2928
- opened
3029
- edited
3130
- synchronize
31+
- reopened
3232

3333
permissions:
3434
pull-requests: read
@@ -60,54 +60,54 @@ feat(ui): Add `Button` component
6060
```
6161

6262
```yml
63-
with:
64-
# Configure which types are allowed (newline-delimited).
65-
# Default: https://github.com/commitizen/conventional-commit-types
66-
types: |
67-
fix
68-
feat
69-
# Configure which scopes are allowed (newline-delimited).
70-
# These are regex patterns auto-wrapped in `^ $`.
71-
scopes: |
72-
core
73-
ui
74-
JIRA-\d+
75-
# Configure that a scope must always be provided.
76-
requireScope: true
77-
# Configure which scopes are disallowed in PR titles (newline-delimited).
78-
# For instance by setting the value below, `chore(release): ...` (lowercase)
79-
# and `ci(e2e,release): ...` (unknown scope) will be rejected.
80-
# These are regex patterns auto-wrapped in `^ $`.
81-
disallowScopes: |
82-
release
83-
[A-Z]+
84-
# Configure additional validation for the subject based on a regex.
85-
# This example ensures the subject doesn't start with an uppercase character.
86-
subjectPattern: ^(?![A-Z]).+$
87-
# If `subjectPattern` is configured, you can use this property to override
88-
# the default error message that is shown when the pattern doesn't match.
89-
# The variables `subject` and `title` can be used within the message.
90-
subjectPatternError: |
91-
The subject "{subject}" found in the pull request title "{title}"
92-
didn't match the configured pattern. Please ensure that the subject
93-
doesn't start with an uppercase character.
94-
# The GitHub base URL will be automatically set to the correct value from the GitHub context variable.
95-
# If you want to override this, you can do so here (not recommended).
96-
githubBaseUrl: https://github.myorg.com/api/v3
97-
# If the PR contains one of these newline-delimited labels, the
98-
# validation is skipped. If you want to rerun the validation when
99-
# labels change, you might want to use the `labeled` and `unlabeled`
100-
# event triggers in your workflow.
101-
ignoreLabels: |
102-
bot
103-
ignore-semantic-pull-request
104-
# If you're using a format for the PR title that differs from the traditional Conventional
105-
# Commits spec, you can use these options to customize the parsing of the type, scope and
106-
# subject. The `headerPattern` should contain a regex where the capturing groups in parentheses
107-
# correspond to the parts listed in `headerPatternCorrespondence`.
108-
# See: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern
109-
headerPattern: '^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$'
110-
headerPatternCorrespondence: type, scope, subject
63+
with:
64+
# Configure which types are allowed (newline-delimited).
65+
# Default: https://github.com/commitizen/conventional-commit-types
66+
types: |
67+
fix
68+
feat
69+
# Configure which scopes are allowed (newline-delimited).
70+
# These are regex patterns auto-wrapped in `^ $`.
71+
scopes: |
72+
core
73+
ui
74+
JIRA-\d+
75+
# Configure that a scope must always be provided.
76+
requireScope: true
77+
# Configure which scopes are disallowed in PR titles (newline-delimited).
78+
# For instance by setting the value below, `chore(release): ...` (lowercase)
79+
# and `ci(e2e,release): ...` (unknown scope) will be rejected.
80+
# These are regex patterns auto-wrapped in `^ $`.
81+
disallowScopes: |
82+
release
83+
[A-Z]+
84+
# Configure additional validation for the subject based on a regex.
85+
# This example ensures the subject doesn't start with an uppercase character.
86+
subjectPattern: ^(?![A-Z]).+$
87+
# If `subjectPattern` is configured, you can use this property to override
88+
# the default error message that is shown when the pattern doesn't match.
89+
# The variables `subject` and `title` can be used within the message.
90+
subjectPatternError: |
91+
The subject "{subject}" found in the pull request title "{title}"
92+
didn't match the configured pattern. Please ensure that the subject
93+
doesn't start with an uppercase character.
94+
# The GitHub base URL will be automatically set to the correct value from the GitHub context variable.
95+
# If you want to override this, you can do so here (not recommended).
96+
githubBaseUrl: https://github.myorg.com/api/v3
97+
# If the PR contains one of these newline-delimited labels, the
98+
# validation is skipped. If you want to rerun the validation when
99+
# labels change, you might want to use the `labeled` and `unlabeled`
100+
# event triggers in your workflow.
101+
ignoreLabels: |
102+
bot
103+
ignore-semantic-pull-request
104+
# If you're using a format for the PR title that differs from the traditional Conventional
105+
# Commits spec, you can use these options to customize the parsing of the type, scope and
106+
# subject. The `headerPattern` should contain a regex where the capturing groups in parentheses
107+
# correspond to the parts listed in `headerPatternCorrespondence`.
108+
# See: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern
109+
headerPattern: '^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$'
110+
headerPatternCorrespondence: type, scope, subject
111111
```
112112
113113
### Work-in-progress pull requests
@@ -144,15 +144,15 @@ jobs:
144144

145145
### Legacy configuration for validating single commits
146146

147-
When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit. As it's easy to commit this by mistake this action supports two configuration options to provide additional validation for this case.
147+
When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit. As it's easy to commit this by mistake this action supports two configuration options to provide additional validation for this case.
148148

149149
```yml
150-
# If the PR only contains a single commit, the action will validate that
151-
# it matches the configured pattern.
152-
validateSingleCommit: true
153-
# Related to `validateSingleCommit` you can opt-in to validate that the PR
154-
# title matches a single commit to avoid confusion.
155-
validateSingleCommitMatchesPrTitle: true
150+
# If the PR only contains a single commit, the action will validate that
151+
# it matches the configured pattern.
152+
validateSingleCommit: true
153+
# Related to `validateSingleCommit` you can opt-in to validate that the PR
154+
# title matches a single commit to avoid confusion.
155+
validateSingleCommitMatchesPrTitle: true
156156
```
157157
158158
However, [GitHub has introduced an option to streamline this behaviour](https://github.blog/changelog/2022-05-11-default-to-pr-titles-for-squash-merge-commit-messages/), so using that instead should be preferred.
@@ -166,14 +166,15 @@ There are two events that can be used as triggers for this action, each with dif
166166

167167
## Outputs
168168

169-
In case the validation fails, this action will populate the `error_message` ouput.
169+
- The outputs `type`, `scope` and `subject` are populated, except for if the `wip` option is used.
170+
- The `error_message` output will be populated in case the validation fails.
170171

171172
[An output can be used in other steps](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs), for example to comment the error message onto the pull request.
172173

173174
<details>
174175
<summary>Example</summary>
175176

176-
````yml
177+
```yml
177178
name: "Lint PR"
178179
179180
on:
@@ -204,21 +205,21 @@ jobs:
204205
header: pr-title-lint-error
205206
message: |
206207
Hey there and thank you for opening this pull request! 👋🏼
207-
208+
208209
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
209210
210211
Details:
211-
212+
212213
```
213214
${{ steps.lint_pr_title.outputs.error_message }}
214215
```
215216

216217
# Delete a previous comment when the issue has been resolved
217218
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
218219
uses: marocchino/sticky-pull-request-comment@v2
219-
with:
220+
with:
220221
header: pr-title-lint-error
221222
delete: true
222-
````
223+
```
223224
224225
</details>

action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: semantic-pull-request
22
description: Ensure your PR title matches the Conventional Commits spec (https://www.conventionalcommits.org/).
33
runs:
4-
using: "node20"
5-
main: "dist/index.js"
4+
using: 'node20'
5+
main: 'dist/index.js'
66
branding:
7-
icon: "shield"
8-
color: "green"
7+
icon: 'shield'
8+
color: 'green'
99
inputs:
1010
types:
1111
description: "Provide custom types (newline delimited) if you don't want the default ones from https://www.conventionalcommits.org."
@@ -17,7 +17,7 @@ inputs:
1717
description: "Configure that a scope must always be provided."
1818
required: false
1919
disallowScopes:
20-
description: "Configure which scopes are disallowed in PR titles (newline delimited). These are regex patterns auto-wrapped in ` ^$`."
20+
description: 'Configure which scopes are disallowed in PR titles (newline delimited). These are regex patterns auto-wrapped in ` ^$`.'
2121
required: false
2222
subjectPattern:
2323
description: "Configure additional validation for the subject based on a regex. E.g. '^(?![A-Z]).+$' ensures the subject doesn't start with an uppercase character."
@@ -26,15 +26,15 @@ inputs:
2626
description: "If `subjectPattern` is configured, you can use this property to override the default error message that is shown when the pattern doesn't match. The variables `subject` and `title` can be used within the message."
2727
required: false
2828
validateSingleCommit:
29-
description: 'When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit, and it''s easy to commit this by mistake. Enable this option to also validate the commit message for one commit PRs.'
29+
description: "When using \"Squash and merge\" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit, and it's easy to commit this by mistake. Enable this option to also validate the commit message for one commit PRs."
3030
required: false
3131
validateSingleCommitMatchesPrTitle:
3232
description: "Related to `validateSingleCommit` you can opt-in to validate that the PR title matches a single commit to avoid confusion."
3333
required: false
3434
githubBaseUrl:
3535
description: "The GitHub base URL will be automatically set to the correct value from the GitHub context variable. If you want to override this, you can do so here (not recommended)."
3636
required: false
37-
default: "${{ github.api_url }}"
37+
default: '${{ github.api_url }}'
3838
ignoreLabels:
3939
description: "If the PR contains one of these labels (newline delimited), the validation is skipped. If you want to rerun the validation when labels change, you might want to use the `labeled` and `unlabeled` event triggers in your workflow."
4040
required: false

0 commit comments

Comments
 (0)