14
14
permissions : write-all
15
15
16
16
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
-
39
17
- name : Generate Token
40
18
id : generate-token
41
19
continue-on-error : true
44
22
app-id : " ${{ secrets.WORKFLOW_AUTH_PUBLIC_APP_ID }}"
45
23
private-key : " ${{ secrets.WORKFLOW_AUTH_PUBLIC_PRIVATE_KEY }}"
46
24
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
-
58
25
- name : Check out code
59
26
uses : actions/checkout@v4
60
27
with :
@@ -129,62 +96,55 @@ jobs:
129
96
130
97
return null;
131
98
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
-
147
99
- name : Post CLA comment and block merge
148
100
if : github.event_name == 'pull_request' && steps.docs-changed.outputs.requires_cla == 'true'
149
101
uses : actions/github-script@v7
150
102
with :
151
103
github-token : ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
152
104
script : |
153
- console.log('=== CLA COMMENT STEP DEBUG ===');
154
- console.log('Event name:', context.eventName);
155
-
156
105
let prNumber, prAuthor;
157
106
158
107
if (context.eventName == 'pull_request') {
159
108
prNumber = context.issue.number;
160
109
prAuthor = '${{ github.event.pull_request.user.login }}';
161
- console.log('PR event - Number:', prNumber, 'Author:', prAuthor);
162
110
}
163
111
164
112
if (!prNumber || !prAuthor) {
165
- console.log('Missing PR number or author, skipping...');
166
113
return;
167
114
}
168
115
169
- console.log(`Processing PR #${prNumber} for author: ${prAuthor}`);
170
-
171
116
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
+
172
136
// Check if CLA comment already exists
173
- console.log('Fetching existing comments...');
174
137
const comments = await github.rest.issues.listComments({
175
138
issue_number: prNumber,
176
139
owner: context.repo.owner,
177
140
repo: context.repo.repo,
178
141
});
179
- console.log(`Found ${comments.data.length} existing comments`);
180
142
181
143
const existingClaComment = comments.data.find(comment =>
182
144
(comment.user.login === 'github-actions[bot]' || comment.user.type === 'Bot') &&
183
145
comment.body.includes('CLA Agreement Required - MERGE BLOCKED')
184
146
);
185
147
186
- console.log('Existing CLA comment found:', !!existingClaComment);
187
-
188
148
if (!existingClaComment && context.eventName === 'pull_request') {
189
149
const claText = `# CLA Agreement Required - MERGE BLOCKED
190
150
@@ -194,7 +154,8 @@ jobs:
194
154
<summary>Click to see Trademark License Addendum</summary>
195
155
196
156
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,
198
159
supplement the terms of the Individual Contributor License Agreement
199
160
between You and the Company ("Agreement"). Capitalized terms not
200
161
defined herein shall have the meanings ascribed to them in the
@@ -248,31 +209,24 @@ jobs:
248
209
**To unblock this PR, reply with exactly:**
249
210
250
211
\`\`\`
251
- I have read and agree to the Contributor License Agreement.
212
+ I have read and agree to the Contributor License Agreement Addendum .
252
213
CLA-SIGNATURE: ${prAuthor}
253
214
\`\`\``;
254
215
255
- console.log('Creating CLA comment...');
256
216
await github.rest.issues.createComment({
257
217
issue_number: prNumber,
258
218
owner: context.repo.owner,
259
219
repo: context.repo.repo,
260
220
body: claText
261
221
});
262
- console.log('CLA comment created successfully');
263
222
264
- console.log('Adding labels...');
265
223
await github.rest.issues.addLabels({
266
224
issue_number: prNumber,
267
225
owner: context.repo.owner,
268
226
repo: context.repo.repo,
269
227
labels: ['cla-required', 'integrations-with-image-change']
270
228
});
271
- console.log('Labels added successfully');
272
- } else {
273
- console.log('CLA comment already exists or not a pull request event');
274
229
}
275
- console.log('=== END CLA COMMENT STEP DEBUG ===');
276
230
} catch (error) {
277
231
console.error('Error in CLA comment step:', error);
278
232
throw error;
0 commit comments