9
9
- edited
10
10
- ready_for_review
11
11
- converted_to_draft
12
- merge_group :
13
12
14
13
permissions :
15
14
pull-requests : write
@@ -20,15 +19,10 @@ jobs:
20
19
runs-on : ubuntu-latest
21
20
steps :
22
21
- name : Check PR title if not sematic
23
- uses : actions/github-script@v6
22
+ uses : actions/github-script@v7
24
23
id : check
25
24
with :
26
25
script : |
27
- if (!context.payload.pull_request) {
28
- core.info('PR payload is null');
29
- core.setOutput('title', 'ignore');
30
- return;
31
- }
32
26
const title = context.payload.pull_request.title;
33
27
const regex = /^(rfc|feat|fix|refactor|ci|docs|chore)(\([a-z0-9-]+\))?:/;
34
28
const m = title.match(regex);
@@ -112,15 +106,10 @@ jobs:
112
106
runs-on : ubuntu-latest
113
107
steps :
114
108
- name : Check CLA if not signed
115
- uses : actions/github-script@v6
109
+ uses : actions/github-script@v7
116
110
id : check
117
111
with :
118
112
script : |
119
- if (!context.payload.pull_request) {
120
- core.info('PR payload is null');
121
- core.setOutput('cla', 'ignore');
122
- return;
123
- }
124
113
const body = context.payload.pull_request.body;
125
114
const regex = /I hereby agree to the terms of the CLA available at: https:\/\/docs.databend.com\/dev\/policies\/cla\//;
126
115
if (!regex.test(body)) {
@@ -154,3 +143,78 @@ jobs:
154
143
155
144
- Close #issue
156
145
```
146
+
147
+ description :
148
+ runs-on : ubuntu-latest
149
+ steps :
150
+ - name : Check PR description checkbox
151
+ uses : actions/github-script@v7
152
+ id : check
153
+ with :
154
+ script : |
155
+ const body = context.payload.pull_request.body;
156
+ const regex = /- [x] /;
157
+ let section = "summary";
158
+ let testsChecked = false;
159
+ let changesChecked = false;
160
+ for (const line of body.split('\n')) {
161
+ if (line ==="## Tests") {
162
+ section = "tests";
163
+ continue;
164
+ } else if (line === "## Type of change") {
165
+ section = "changes";
166
+ continue;
167
+ }
168
+ if (section === "tests") {
169
+ if (regex.test(line)) {
170
+ testsChecked = true;
171
+ core.setOutput('tests', 'fulfilled');
172
+ continue;
173
+ }
174
+ }
175
+ if (section === "changes") {
176
+ if (regex.test(line)) {
177
+ changesChecked = true;
178
+ core.setOutput('changes', 'fulfilled');
179
+ continue;
180
+ }
181
+ }
182
+ }
183
+ if (!testsChecked) {
184
+ core.setOutput('tests', 'not-fulfilled');
185
+ core.error('Tests are not checked');
186
+ }
187
+ if (!changesChecked) {
188
+ core.setOutput('changes', 'not-fulfilled');
189
+ core.error('Type of Changes are not checked');
190
+ }
191
+ - name : Delete Comment for Tests
192
+ if : steps.check.outputs.tests == 'fullfilled'
193
+ uses : everpcpc/comment-on-pr-action@v1
194
+ with :
195
+ token : ${{ github.token }}
196
+ identifier : ' pr-assistant-description-tests'
197
+ delete : true
198
+ - name : Delete Comment for Changes
199
+ if : steps.check.outputs.changes == 'fullfilled'
200
+ uses : everpcpc/comment-on-pr-action@v1
201
+ with :
202
+ token : ${{ github.token }}
203
+ identifier : ' pr-assistant-description-changes'
204
+ delete : true
205
+ - name : Comment on PR for Tests
206
+ if : steps.check.outputs.tests != 'fullfilled'
207
+ uses : everpcpc/comment-on-pr-action@v1
208
+ with :
209
+ token : ${{ github.token }}
210
+ identifier : ' pr-assistant-description-tests'
211
+ body : |
212
+ At least one test case must be checked in the PR description.
213
+ - name : Comment on PR for Changes
214
+ if : steps.check.outputs.changes != 'fullfilled'
215
+ uses : everpcpc/comment-on-pr-action@v1
216
+ with :
217
+ token : ${{ github.token }}
218
+ identifier : ' pr-assistant-description-changes'
219
+ body : |
220
+ At least one type of change must be checked in the PR description.
0 commit comments