Skip to content

Commit 127e107

Browse files
committed
remove deubgging and make some more improvements (exclude clickhouse members)
1 parent cfb44cd commit 127e107

File tree

2 files changed

+23
-109
lines changed

2 files changed

+23
-109
lines changed

.github/workflows/trademark-cla-approval.yml

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@ jobs:
1818
if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'cla-signed'
1919

2020
steps:
21-
- name: Debug - Event info
22-
run: |
23-
echo "=== CLA APPROVAL DEBUG ==="
24-
echo "Event: ${{ github.event_name }}"
25-
echo "Action: ${{ github.event.action }}"
26-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
27-
echo "Manual trigger - PR: ${{ github.event.inputs.pr_number }}"
28-
else
29-
echo "Label: ${{ github.event.label.name }}"
30-
echo "Added by: ${{ github.actor }}"
31-
echo "PR number: ${{ github.event.number }}"
32-
fi
33-
echo "================================="
3421

3522
- name: Generate Token
3623
id: generate-token
@@ -45,35 +32,24 @@ jobs:
4532
with:
4633
github-token: ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
4734
script: |
48-
console.log('=== PROCESSING CLA APPROVAL ===');
49-
console.log('Event:', context.eventName);
50-
console.log('Actor:', context.actor);
51-
5235
let prNumber;
5336
5437
// Determine PR number
5538
if (context.eventName === 'workflow_dispatch') {
5639
prNumber = parseInt('${{ github.event.inputs.pr_number }}');
57-
console.log('Manual trigger for PR:', prNumber);
5840
} else if (context.eventName === 'pull_request') {
5941
prNumber = context.payload.pull_request.number;
60-
console.log('Label trigger for PR:', prNumber);
61-
console.log('Label added:', context.payload.label.name);
6242
} else {
63-
console.log('Unexpected event type, skipping...');
6443
return;
6544
}
6645
67-
console.log('Processing CLA approval for PR:', prNumber);
68-
6946
// Get PR details
7047
const { data: pr } = await github.rest.pulls.get({
7148
owner: context.repo.owner,
7249
repo: context.repo.repo,
7350
pull_number: prNumber
7451
});
7552
76-
console.log('PR author:', pr.user.login);
7753
7854
// Check if the person triggering has the right permissions
7955
try {
@@ -83,14 +59,10 @@ jobs:
8359
username: context.actor
8460
});
8561
86-
console.log('Actor permission level:', collaboration.permission);
87-
8862
// Only admin, maintain, or write permissions can approve CLA
8963
const isAuthorized = ['admin', 'maintain', 'write'].includes(collaboration.permission);
90-
console.log('Is authorized to approve CLA:', isAuthorized);
9164
9265
if (!isAuthorized) {
93-
console.log('User does not have permission to approve CLA');
9466
9567
// If this was a label event, remove the label
9668
if (context.eventName !== 'workflow_dispatch') {
@@ -110,7 +82,6 @@ jobs:
11082
body: `@${context.actor} Only repository maintainers can approve CLAs. ${context.eventName !== 'workflow_dispatch' ? 'The label has been removed.' : ''}`
11183
});
11284
113-
console.log('Unauthorized approval attempt blocked');
11485
return;
11586
}
11687
@@ -122,17 +93,14 @@ jobs:
12293
});
12394
12495
const hasClaMeeded = labels.some(label => label.name === 'cla-required');
125-
console.log('PR has cla-required label:', hasClaMeeded);
12696
12797
if (!hasClaMeeded) {
128-
console.log('PR does not have cla-required label, no action needed');
12998
return;
13099
}
131100
132101
// Ensure cla-signed label is present
133102
const hasClaSigned = labels.some(label => label.name === 'cla-signed');
134103
if (!hasClaSigned) {
135-
console.log('Adding cla-signed label...');
136104
await github.rest.issues.addLabels({
137105
owner: context.repo.owner,
138106
repo: context.repo.repo,
@@ -142,7 +110,6 @@ jobs:
142110
}
143111
144112
// Authorized - proceed with approval
145-
console.log('Processing authorized CLA approval...');
146113
147114
// Remove the blocking label
148115
try {
@@ -152,9 +119,8 @@ jobs:
152119
issue_number: prNumber,
153120
name: 'cla-required'
154121
});
155-
console.log('Removed cla-required label');
156122
} catch (e) {
157-
console.log('cla-required label not found or already removed:', e.message);
123+
// Label not found or already removed
158124
}
159125
160126
// Check if confirmation comment already exists
@@ -185,14 +151,8 @@ jobs:
185151
186152
This PR is now unblocked and can proceed with normal review!`
187153
});
188-
console.log('Posted confirmation comment');
189154
}
190155
191-
console.log('CLA approval completed successfully');
192-
193156
} catch (error) {
194-
console.error('Error processing CLA approval:', error);
195157
throw error;
196158
}
197-
198-
console.log('=== END CLA APPROVAL PROCESSING ===');

.github/workflows/trademark-cla-notice.yml

Lines changed: 22 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,6 @@ jobs:
1414
permissions: write-all
1515

1616
steps:
17-
- name: Debug - Check if secrets exist
18-
run: |
19-
echo "=== SECRET CHECK ==="
20-
if [ -z "${{ secrets.WORKFLOW_AUTH_PUBLIC_APP_ID }}" ]; then
21-
echo "WORKFLOW_AUTH_PUBLIC_APP_ID is empty or not set"
22-
else
23-
echo "WORKFLOW_AUTH_PUBLIC_APP_ID is set"
24-
fi
25-
26-
if [ -z "${{ secrets.WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY }}" ]; then
27-
echo "WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY is empty or not set"
28-
else
29-
echo "WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY is set"
30-
fi
31-
32-
if [ -z "${{ secrets.GITHUB_PAT }}" ]; then
33-
echo "GITHUB_PAT is empty or not set"
34-
else
35-
echo "GITHUB_PAT is set"
36-
fi
37-
echo "==================="
38-
3917
- name: Generate Token
4018
id: generate-token
4119
continue-on-error: true
@@ -44,17 +22,6 @@ jobs:
4422
app-id: "${{ secrets.WORKFLOW_AUTH_PUBLIC_APP_ID }}"
4523
private-key: "${{ secrets.WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY }}"
4624

47-
- name: Debug - Token generation result
48-
run: |
49-
echo "=== TOKEN GENERATION RESULT ==="
50-
echo "Token step outcome: ${{ steps.generate-token.outcome }}"
51-
if [ "${{ steps.generate-token.outcome }}" = "success" ]; then
52-
echo "GitHub App token generated successfully"
53-
else
54-
echo "GitHub App token generation failed - will use GITHUB_TOKEN"
55-
fi
56-
echo "================================="
57-
5825
- name: Check out code
5926
uses: actions/checkout@v4
6027
with:
@@ -129,62 +96,55 @@ jobs:
12996
13097
return null;
13198
132-
- name: Debug - CLA requirement check
133-
run: |
134-
echo "=== CLA REQUIREMENT DEBUG ==="
135-
echo "Event name: ${{ github.event_name }}"
136-
echo "Event action: ${{ github.event.action }}"
137-
138-
if [ "${{ github.event_name }}" = "pull_request" ]; then
139-
echo "PR event - docs changed: ${{ steps.docs-changed.outputs.docs_changed }}"
140-
echo "PR event - requires CLA: ${{ steps.docs-changed.outputs.requires_cla }}"
141-
fi
142-
143-
POST_CLA_CONDITION="${{ github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true' }}"
144-
echo "Post CLA comment workflow will run: $POST_CLA_CONDITION"
145-
echo "================================="
146-
14799
- name: Post CLA comment and block merge
148100
if: github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true'
149101
uses: actions/github-script@v7
150102
with:
151103
github-token: ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
152104
script: |
153-
console.log('=== CLA COMMENT STEP DEBUG ===');
154-
console.log('Event name:', context.eventName);
155-
156105
let prNumber, prAuthor;
157106
158107
if (context.eventName == 'pull_request') {
159108
prNumber = context.issue.number;
160109
prAuthor = '${{ github.event.pull_request.user.login }}';
161-
console.log('PR event - Number:', prNumber, 'Author:', prAuthor);
162110
}
163111
164112
if (!prNumber || !prAuthor) {
165-
console.log('Missing PR number or author, skipping...');
166113
return;
167114
}
168115
169-
console.log(`Processing PR #${prNumber} for author: ${prAuthor}`);
170-
171116
try {
117+
// Check if user is in @ClickHouse/everyone team
118+
let isClickHouseMember = false;
119+
try {
120+
await github.rest.teams.getMembershipForUserInOrg({
121+
org: 'ClickHouse',
122+
team_slug: 'everyone',
123+
username: prAuthor
124+
});
125+
isClickHouseMember = true;
126+
} catch (error) {
127+
// User is not in the team or team doesn't exist
128+
isClickHouseMember = false;
129+
}
130+
131+
// Skip CLA requirement for ClickHouse team members
132+
if (isClickHouseMember) {
133+
return;
134+
}
135+
172136
// Check if CLA comment already exists
173-
console.log('Fetching existing comments...');
174137
const comments = await github.rest.issues.listComments({
175138
issue_number: prNumber,
176139
owner: context.repo.owner,
177140
repo: context.repo.repo,
178141
});
179-
console.log(`Found ${comments.data.length} existing comments`);
180142
181143
const existingClaComment = comments.data.find(comment =>
182144
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
183145
comment.body.includes('CLA Agreement Required - MERGE BLOCKED')
184146
);
185147
186-
console.log('Existing CLA comment found:', !!existingClaComment);
187-
188148
if (!existingClaComment && context.eventName === 'pull_request') {
189149
const claText = `# CLA Agreement Required - MERGE BLOCKED
190150
@@ -194,7 +154,8 @@ jobs:
194154
<summary>Click to see Trademark License Addendum</summary>
195155
196156
This Trademark License Addendum ("Addendum") shall, if You have opted
197-
in by checking the appropriate box that references this Addendum,
157+
in by replying to the comment that references this Addendum that you
158+
have read and agree to theContributor License Agreement Addendum,
198159
supplement the terms of the Individual Contributor License Agreement
199160
between You and the Company ("Agreement"). Capitalized terms not
200161
defined herein shall have the meanings ascribed to them in the
@@ -248,31 +209,24 @@ jobs:
248209
**To unblock this PR, reply with exactly:**
249210
250211
\`\`\`
251-
I have read and agree to the Contributor License Agreement.
212+
I have read and agree to the Contributor License Agreement Addendum.
252213
CLA-SIGNATURE: ${prAuthor}
253214
\`\`\``;
254215
255-
console.log('Creating CLA comment...');
256216
await github.rest.issues.createComment({
257217
issue_number: prNumber,
258218
owner: context.repo.owner,
259219
repo: context.repo.repo,
260220
body: claText
261221
});
262-
console.log('CLA comment created successfully');
263222
264-
console.log('Adding labels...');
265223
await github.rest.issues.addLabels({
266224
issue_number: prNumber,
267225
owner: context.repo.owner,
268226
repo: context.repo.repo,
269227
labels: ['cla-required', 'integrations-with-image-change']
270228
});
271-
console.log('Labels added successfully');
272-
} else {
273-
console.log('CLA comment already exists or not a pull request event');
274229
}
275-
console.log('=== END CLA COMMENT STEP DEBUG ===');
276230
} catch (error) {
277231
console.error('Error in CLA comment step:', error);
278232
throw error;

0 commit comments

Comments
 (0)