@@ -131,6 +131,27 @@ jobs:
131
131
132
132
return null;
133
133
134
+ - name : Debug - CLA requirement check
135
+ run : |
136
+ echo "=== CLA REQUIREMENT DEBUG ==="
137
+ echo "Event name: ${{ github.event_name }}"
138
+
139
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
140
+ echo "PR event - docs changed: ${{ steps.docs-changed.outputs.docs_changed }}"
141
+ echo "PR event - requires CLA: ${{ steps.docs-changed.outputs.requires_cla }}"
142
+ fi
143
+
144
+ if [ "${{ github.event_name }}" = "issue_comment" ]; then
145
+ echo "Comment event - has docs changes: ${{ steps.pr-info.outputs.has_docs_changes }}"
146
+ echo "Comment event - PR number: ${{ steps.pr-info.outputs.pr_number }}"
147
+ echo "Comment event - PR author: ${{ steps.pr-info.outputs.pr_author }}"
148
+ echo "Comment event - is ClickHouse member: ${{ steps.pr-info.outputs.isClickHouseMember }}"
149
+ fi
150
+
151
+ CLA_CONDITION="${{ (github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true') || (github.event_name == 'issue_comment' && steps.pr-info.outputs.has_docs_changes == 'true') }}"
152
+ echo "CLA workflow will run: $CLA_CONDITION"
153
+ echo "================================="
154
+
134
155
- name : Post CLA comment and block merge
135
156
if : |
136
157
((github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true') ||
@@ -139,14 +160,19 @@ jobs:
139
160
with :
140
161
github-token : ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
141
162
script : |
163
+ console.log('=== CLA COMMENT STEP DEBUG ===');
164
+ console.log('Event name:', context.eventName);
165
+
142
166
let prNumber, prAuthor;
143
167
144
168
if (context.eventName == 'pull_request') {
145
169
prNumber = context.issue.number;
146
170
prAuthor = '${{ github.event.pull_request.user.login }}';
171
+ console.log('PR event - Number:', prNumber, 'Author:', prAuthor);
147
172
} else {
148
173
prNumber = ${{ steps.pr-info.outputs.pr_number || 'null' }};
149
174
prAuthor = '${{ steps.pr-info.outputs.pr_author }}';
175
+ console.log('Comment event - Number:', prNumber, 'Author:', prAuthor);
150
176
}
151
177
152
178
if (!prNumber || !prAuthor) {
@@ -158,17 +184,21 @@ jobs:
158
184
159
185
try {
160
186
// Check if CLA comment already exists
187
+ console.log('Fetching existing comments...');
161
188
const comments = await github.rest.issues.listComments({
162
189
issue_number: prNumber,
163
190
owner: context.repo.owner,
164
191
repo: context.repo.repo,
165
192
});
193
+ console.log(`Found ${comments.data.length} existing comments`);
166
194
167
195
const existingClaComment = comments.data.find(comment =>
168
196
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
169
197
comment.body.includes('CLA Agreement Required - MERGE BLOCKED')
170
198
);
171
199
200
+ console.log('Existing CLA comment found:', !!existingClaComment);
201
+
172
202
if (!existingClaComment && context.eventName === 'pull_request') {
173
203
const claText = `# CLA Agreement Required - MERGE BLOCKED
174
204
@@ -243,6 +273,7 @@ jobs:
243
273
repo: context.repo.repo,
244
274
body: claText
245
275
});
276
+ console.log('CLA comment created successfully');
246
277
247
278
console.log('Adding labels...');
248
279
await github.rest.issues.addLabels({
@@ -251,11 +282,11 @@ jobs:
251
282
repo: context.repo.repo,
252
283
labels: ['cla-required', 'docs-changes']
253
284
});
254
-
255
- console.log('CLA comment and labels added successfully');
285
+ console.log('Labels added successfully');
256
286
} else {
257
287
console.log('CLA comment already exists or not a pull request event');
258
288
}
289
+ console.log('=== END CLA COMMENT STEP DEBUG ===');
259
290
} catch (error) {
260
291
console.error('Error in CLA comment step:', error);
261
292
throw error;
@@ -269,16 +300,21 @@ jobs:
269
300
with :
270
301
github-token : ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
271
302
script : |
303
+ console.log('=== CLA AGREEMENT CHECK DEBUG ===');
304
+ console.log('Event name:', context.eventName);
305
+
272
306
let prNumber, prHeadSha, prAuthor;
273
307
274
308
if (context.eventName === 'pull_request') {
275
309
prNumber = context.issue.number;
276
310
prHeadSha = '${{ github.event.pull_request.head.sha }}';
277
311
prAuthor = '${{ github.event.pull_request.user.login }}';
312
+ console.log('PR event - Number:', prNumber, 'SHA:', prHeadSha, 'Author:', prAuthor);
278
313
} else {
279
314
prNumber = ${{ steps.pr-info.outputs.pr_number || 'null' }};
280
315
prHeadSha = '${{ steps.pr-info.outputs.pr_head_sha }}';
281
316
prAuthor = '${{ steps.pr-info.outputs.pr_author }}';
317
+ console.log('Comment event - Number:', prNumber, 'SHA:', prHeadSha, 'Author:', prAuthor);
282
318
}
283
319
284
320
if (!prNumber) {
@@ -290,18 +326,31 @@ jobs:
290
326
291
327
try {
292
328
// Get all comments to check for CLA agreement
329
+ console.log('Fetching all comments for CLA check...');
293
330
const comments = await github.rest.issues.listComments({
294
331
issue_number: prNumber,
295
332
owner: context.repo.owner,
296
333
repo: context.repo.repo,
297
334
});
335
+ console.log(`Found ${comments.data.length} comments to check`);
298
336
299
337
const claAgreed = comments.data.some(comment => {
300
- return comment.user.login === prAuthor &&
301
- comment.body.includes('I have read and agree to the Contributor License Agreement') &&
302
- comment.body.includes(`CLA-SIGNATURE: ${prAuthor}`);
338
+ const isAuthor = comment.user.login === prAuthor;
339
+ const hasAgreement = comment.body.includes('I have read and agree to the Contributor License Agreement');
340
+ const hasSignature = comment.body.includes(`CLA-SIGNATURE: ${prAuthor}`);
341
+
342
+ if (isAuthor && (hasAgreement || hasSignature)) {
343
+ console.log(`Found potential CLA comment from ${comment.user.login}:`);
344
+ console.log('- Has agreement text:', hasAgreement);
345
+ console.log('- Has signature:', hasSignature);
346
+ console.log('- Comment body preview:', comment.body.substring(0, 100) + '...');
347
+ }
348
+
349
+ return isAuthor && hasAgreement && hasSignature;
303
350
});
304
351
352
+ console.log('CLA agreement status:', claAgreed);
353
+
305
354
if (claAgreed) {
306
355
console.log('CLA agreement found, removing blocking labels...');
307
356
@@ -313,8 +362,9 @@ jobs:
313
362
repo: context.repo.repo,
314
363
name: 'cla-required'
315
364
});
365
+ console.log('Removed cla-required label');
316
366
} catch (e) {
317
- console.log('Label cla-required not found or already removed' );
367
+ console.log('Label cla-required not found or already removed:', e.message );
318
368
}
319
369
320
370
await github.rest.issues.addLabels({
@@ -323,12 +373,14 @@ jobs:
323
373
repo: context.repo.repo,
324
374
labels: ['cla-signed']
325
375
});
376
+ console.log('Added cla-signed label');
326
377
327
378
// Post confirmation
328
379
const confirmationExists = comments.data.some(comment =>
329
380
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
330
381
comment.body.includes('CLA Agreement Confirmed')
331
382
);
383
+ console.log('Confirmation comment exists:', confirmationExists);
332
384
333
385
if (!confirmationExists) {
334
386
await github.rest.issues.createComment({
@@ -344,6 +396,7 @@ jobs:
344
396
345
397
This PR is now unblocked and can proceed with normal review!`
346
398
});
399
+ console.log('Posted confirmation comment');
347
400
}
348
401
349
402
console.log('CLA processing completed successfully');
@@ -352,6 +405,7 @@ jobs:
352
405
// CLA not agreed - keep it blocked
353
406
core.setFailed('Documentation CLA agreement required before merge');
354
407
}
408
+ console.log('=== END CLA AGREEMENT CHECK DEBUG ===');
355
409
} catch (error) {
356
410
console.error('Error in CLA agreement check:', error);
357
411
throw error;
0 commit comments