Skip to content

Commit c508018

Browse files
committed
Troubleshoot manual rerun
1 parent 2c62230 commit c508018

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

.github/workflows/trademark-cla.yml

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,27 @@ jobs:
131131
132132
return null;
133133
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+
134155
- name: Post CLA comment and block merge
135156
if: |
136157
((github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true') ||
@@ -139,14 +160,19 @@ jobs:
139160
with:
140161
github-token: ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
141162
script: |
163+
console.log('=== CLA COMMENT STEP DEBUG ===');
164+
console.log('Event name:', context.eventName);
165+
142166
let prNumber, prAuthor;
143167
144168
if (context.eventName == 'pull_request') {
145169
prNumber = context.issue.number;
146170
prAuthor = '${{ github.event.pull_request.user.login }}';
171+
console.log('PR event - Number:', prNumber, 'Author:', prAuthor);
147172
} else {
148173
prNumber = ${{ steps.pr-info.outputs.pr_number || 'null' }};
149174
prAuthor = '${{ steps.pr-info.outputs.pr_author }}';
175+
console.log('Comment event - Number:', prNumber, 'Author:', prAuthor);
150176
}
151177
152178
if (!prNumber || !prAuthor) {
@@ -158,17 +184,21 @@ jobs:
158184
159185
try {
160186
// Check if CLA comment already exists
187+
console.log('Fetching existing comments...');
161188
const comments = await github.rest.issues.listComments({
162189
issue_number: prNumber,
163190
owner: context.repo.owner,
164191
repo: context.repo.repo,
165192
});
193+
console.log(`Found ${comments.data.length} existing comments`);
166194
167195
const existingClaComment = comments.data.find(comment =>
168196
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
169197
comment.body.includes('CLA Agreement Required - MERGE BLOCKED')
170198
);
171199
200+
console.log('Existing CLA comment found:', !!existingClaComment);
201+
172202
if (!existingClaComment && context.eventName === 'pull_request') {
173203
const claText = `# CLA Agreement Required - MERGE BLOCKED
174204
@@ -243,6 +273,7 @@ jobs:
243273
repo: context.repo.repo,
244274
body: claText
245275
});
276+
console.log('CLA comment created successfully');
246277
247278
console.log('Adding labels...');
248279
await github.rest.issues.addLabels({
@@ -251,11 +282,11 @@ jobs:
251282
repo: context.repo.repo,
252283
labels: ['cla-required', 'docs-changes']
253284
});
254-
255-
console.log('CLA comment and labels added successfully');
285+
console.log('Labels added successfully');
256286
} else {
257287
console.log('CLA comment already exists or not a pull request event');
258288
}
289+
console.log('=== END CLA COMMENT STEP DEBUG ===');
259290
} catch (error) {
260291
console.error('Error in CLA comment step:', error);
261292
throw error;
@@ -269,16 +300,21 @@ jobs:
269300
with:
270301
github-token: ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
271302
script: |
303+
console.log('=== CLA AGREEMENT CHECK DEBUG ===');
304+
console.log('Event name:', context.eventName);
305+
272306
let prNumber, prHeadSha, prAuthor;
273307
274308
if (context.eventName === 'pull_request') {
275309
prNumber = context.issue.number;
276310
prHeadSha = '${{ github.event.pull_request.head.sha }}';
277311
prAuthor = '${{ github.event.pull_request.user.login }}';
312+
console.log('PR event - Number:', prNumber, 'SHA:', prHeadSha, 'Author:', prAuthor);
278313
} else {
279314
prNumber = ${{ steps.pr-info.outputs.pr_number || 'null' }};
280315
prHeadSha = '${{ steps.pr-info.outputs.pr_head_sha }}';
281316
prAuthor = '${{ steps.pr-info.outputs.pr_author }}';
317+
console.log('Comment event - Number:', prNumber, 'SHA:', prHeadSha, 'Author:', prAuthor);
282318
}
283319
284320
if (!prNumber) {
@@ -290,18 +326,31 @@ jobs:
290326
291327
try {
292328
// Get all comments to check for CLA agreement
329+
console.log('Fetching all comments for CLA check...');
293330
const comments = await github.rest.issues.listComments({
294331
issue_number: prNumber,
295332
owner: context.repo.owner,
296333
repo: context.repo.repo,
297334
});
335+
console.log(`Found ${comments.data.length} comments to check`);
298336
299337
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;
303350
});
304351
352+
console.log('CLA agreement status:', claAgreed);
353+
305354
if (claAgreed) {
306355
console.log('CLA agreement found, removing blocking labels...');
307356
@@ -313,8 +362,9 @@ jobs:
313362
repo: context.repo.repo,
314363
name: 'cla-required'
315364
});
365+
console.log('Removed cla-required label');
316366
} 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);
318368
}
319369
320370
await github.rest.issues.addLabels({
@@ -323,12 +373,14 @@ jobs:
323373
repo: context.repo.repo,
324374
labels: ['cla-signed']
325375
});
376+
console.log('Added cla-signed label');
326377
327378
// Post confirmation
328379
const confirmationExists = comments.data.some(comment =>
329380
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
330381
comment.body.includes('CLA Agreement Confirmed')
331382
);
383+
console.log('Confirmation comment exists:', confirmationExists);
332384
333385
if (!confirmationExists) {
334386
await github.rest.issues.createComment({
@@ -344,6 +396,7 @@ jobs:
344396
345397
This PR is now unblocked and can proceed with normal review!`
346398
});
399+
console.log('Posted confirmation comment');
347400
}
348401
349402
console.log('CLA processing completed successfully');
@@ -352,6 +405,7 @@ jobs:
352405
// CLA not agreed - keep it blocked
353406
core.setFailed('Documentation CLA agreement required before merge');
354407
}
408+
console.log('=== END CLA AGREEMENT CHECK DEBUG ===');
355409
} catch (error) {
356410
console.error('Error in CLA agreement check:', error);
357411
throw error;

0 commit comments

Comments
 (0)