9
9
10
10
comment-header :
11
11
description : " Header line for the PR comment."
12
- default : " :black_nib: Commitlint PR Title"
12
+ default : " :black_nib: PR Title Commitlint"
13
+ type : string
14
+
15
+ comment-success :
16
+ description : " Success message for the PR comment."
17
+ default : " :heavy_check_mark: Lint success!"
18
+ type : string
19
+
20
+ comment-error :
21
+ description : " Error message for the PR comment."
22
+ default : " :x: Lint error! Fix title before merging!"
13
23
type : string
14
24
15
25
config :
50
60
shell : bash
51
61
run : |
52
62
set +e
53
- lint=$(echo "$TITLE" | npx commitlint --config="$CONFIG")
63
+ lint=$(echo "$TITLE" | npx commitlint --config="$CONFIG" --help-url="$CONFIG" )
54
64
status=$?
55
65
echo "$lint"
56
66
printf "lint<<EOF\n%s\nEOF" "${lint}" >> "$GITHUB_OUTPUT"
59
69
TITLE : ${{ github.event.pull_request.title }}
60
70
CONFIG : ${{ inputs.config }}
61
71
72
+ - name : create step summary on bad lint
73
+ if : always() && steps.commitlint.outcome != 'success'
74
+ shell : bash
75
+ run : |
76
+ printf "%s" "${SUMMARY}" >> "$GITHUB_STEP_SUMMARY"
77
+ printf "COMMENT_BODY<<EOF\n%s\nEOF" "${SUMMARY}" >> "$GITHUB_ENV"
78
+ env :
79
+ # Note the intentional double spaces at the end of some lines. This is markdown.
80
+ SUMMARY : |
81
+ #### ${{ inputs.comment-header }} - ${{ inputs.comment-error }}
82
+ Expected PR title to be conventional commit format: ie. `type(scope): summary`
83
+ ```
84
+ ${{ steps.commitlint.outputs.lint }}
85
+ ```
86
+ Conventional Commits :open_book: [Docs](https://www.conventionalcommits.org/en/v1.0.0)
87
+ Commitlint :file_cabinet: [Config](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${{ inputs.config }}) :open_book: [Docs](https://commitlint.js.org/reference/rules)
88
+
89
+ - name : create step summary on good lint
90
+ if : always() && steps.commitlint.outcome == 'success'
91
+ shell : bash
92
+ run : |
93
+ printf "%s" "${SUMMARY}" >> "$GITHUB_STEP_SUMMARY"
94
+ printf "COMMENT_BODY<<EOF\n%s\nEOF" "${SUMMARY}" >> "$GITHUB_ENV"
95
+ env :
96
+ SUMMARY : |
97
+ #### ${{ inputs.comment-header }} - ${{ inputs.comment-success }}
98
+
62
99
- name : find pr comment
63
100
uses : peter-evans/find-comment@v3
64
101
if : always()
@@ -68,28 +105,15 @@ jobs:
68
105
body-includes : ${{ inputs.comment-header }}
69
106
comment-author : " github-actions[bot]"
70
107
71
- - name : create or update pr comment on bad lint
72
- uses : peter-evans/create-or-update-comment@v4
73
- if : always() && steps.commitlint.outcome == 'failure'
74
- with :
75
- comment-id : ${{ steps.find-pr-comment.outputs.comment-id }}
76
- issue-number : ${{ github.event.pull_request.number }}
77
- edit-mode : replace
78
- body : |
79
- #### :x: ${{ inputs.comment-header }} - Fix title before merge!
80
- ```
81
- ${{ steps.commitlint.outputs.lint }}
82
- ```
83
-
84
- - name : create or update pr comment on successful lint
108
+ - name : create or update pr comment
85
109
uses : peter-evans/create-or-update-comment@v4
86
- if : always() && steps.commitlint.outcome == 'success'
110
+ if : always() && ( steps.commitlint.outcome == 'success' || steps.commitlint.outcome == 'failure')
87
111
with :
88
112
comment-id : ${{ steps.find-pr-comment.outputs.comment-id }}
89
113
issue-number : ${{ github.event.pull_request.number }}
90
114
edit-mode : replace
91
115
body : |
92
- #### :heavy_check_mark: ${{ inputs.comment-header }} - Good Title
116
+ ${{ env.COMMENT_BODY }}
93
117
94
118
- name : add error label on bad lint
95
119
uses : actions/github-script@v7.0.1
0 commit comments