You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-62Lines changed: 63 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,6 @@ See [Conventional Commits](https://www.conventionalcommits.org/) for more exampl
19
19
20
20
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".
21
21
2.[Add the action](https://docs.github.com/en/actions/quickstart) with the following configuration:
### Legacy configuration for validating single commits
146
146
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.
148
148
149
149
```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
156
156
```
157
157
158
158
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
166
166
167
167
## Outputs
168
168
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.
170
171
171
172
[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.
172
173
173
174
<details>
174
175
<summary>Example</summary>
175
176
176
-
````yml
177
+
```yml
177
178
name: "Lint PR"
178
179
179
180
on:
@@ -204,21 +205,21 @@ jobs:
204
205
header: pr-title-lint-error
205
206
message: |
206
207
Hey there and thank you for opening this pull request! 👋🏼
207
-
208
+
208
209
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.
209
210
210
211
Details:
211
-
212
+
212
213
```
213
214
${{ steps.lint_pr_title.outputs.error_message }}
214
215
```
215
216
216
217
# Delete a previous comment when the issue has been resolved
Copy file name to clipboardExpand all lines: action.yml
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
name: semantic-pull-request
2
2
description: Ensure your PR title matches the Conventional Commits spec (https://www.conventionalcommits.org/).
3
3
runs:
4
-
using: "node20"
5
-
main: "dist/index.js"
4
+
using: 'node20'
5
+
main: 'dist/index.js'
6
6
branding:
7
-
icon: "shield"
8
-
color: "green"
7
+
icon: 'shield'
8
+
color: 'green'
9
9
inputs:
10
10
types:
11
11
description: "Provide custom types (newline delimited) if you don't want the default ones from https://www.conventionalcommits.org."
@@ -17,7 +17,7 @@ inputs:
17
17
description: "Configure that a scope must always be provided."
18
18
required: false
19
19
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 ` ^$`.'
21
21
required: false
22
22
subjectPattern:
23
23
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:
26
26
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."
27
27
required: false
28
28
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."
30
30
required: false
31
31
validateSingleCommitMatchesPrTitle:
32
32
description: "Related to `validateSingleCommit` you can opt-in to validate that the PR title matches a single commit to avoid confusion."
33
33
required: false
34
34
githubBaseUrl:
35
35
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)."
36
36
required: false
37
-
default: "${{ github.api_url }}"
37
+
default: '${{ github.api_url }}'
38
38
ignoreLabels:
39
39
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."
0 commit comments