@@ -254,99 +254,35 @@ jobs:
254
254
# Add the file to git and commit
255
255
git add "$SIGNATURES_FILE"
256
256
257
- # Check if there are staged changes
258
- if ! git diff --cached --quiet; then
259
- IS_FORK="${{ steps.process-comment.outputs.is_fork }}"
260
-
261
- if [ "$IS_FORK" = "true" ]; then
262
- echo "Fork detected - will create PR with signature changes"
263
- # Create a unique branch name for the signature
264
- TIMESTAMP=$(date +%s)
265
- SIGNATURE_BRANCH="trademark-signature-$USERNAME-pr-$PR_NUMBER-$TIMESTAMP"
266
-
267
- # Switch to main and create new branch
268
- git fetch origin main
269
- git checkout -b "$SIGNATURE_BRANCH" origin/main
270
-
271
- # Re-apply our signature file changes to the new branch
272
- mkdir -p contribute
273
- if [ ! -f "$SIGNATURES_FILE" ]; then
274
- echo '{"signatures": []}' > "$SIGNATURES_FILE"
275
- fi
276
-
277
- # Re-add the signature (check if already exists to avoid duplicates)
278
- EXISTING=$(jq --arg user "$USERNAME" --arg pr "$PR_NUMBER" '.signatures[] | select(.username == $user and .pr_number == ($pr | tonumber))' "$SIGNATURES_FILE" 2>/dev/null || echo "")
279
- if [ -z "$EXISTING" ]; then
280
- jq --arg user "$USERNAME" \
281
- --arg date "$DATE" \
282
- --arg pr "$PR_NUMBER" \
283
- --arg approved_by "$APPROVED_BY" \
284
- '.signatures += [{
285
- "username": $user,
286
- "date": $date,
287
- "pr_number": ($pr | tonumber),
288
- "approved_by": $approved_by
289
- }]' "$SIGNATURES_FILE" > tmp.json && mv tmp.json "$SIGNATURES_FILE"
290
- fi
291
-
292
- git add "$SIGNATURES_FILE"
293
- git commit -m "Add trademark addendum signature for @$USERNAME (PR #$PR_NUMBER)" \
294
- -m "This signature was recorded automatically by the CLA approval workflow."
295
-
296
- # Push the new branch
297
- git push origin "$SIGNATURE_BRANCH"
298
-
299
- # Store branch name for next step
300
- echo "signature_branch=$SIGNATURE_BRANCH" >> $GITHUB_OUTPUT
301
- echo "✅ Signature committed to branch $SIGNATURE_BRANCH"
302
- else
303
- echo "Non-fork PR - committing to current branch"
304
- git commit -m "Add trademark addendum signature for @$USERNAME (PR #$PR_NUMBER)" \
305
- -m "This signature was recorded automatically by the CLA approval workflow."
306
- git push
307
- echo "✅ Signature committed and pushed successfully"
308
- fi
257
+ # Store signature in ClickHouse
258
+ echo "Storing signature in ClickHouse..."
259
+
260
+ # Format date for ClickHouse DateTime (YYYY-MM-DD HH:MM:SS)
261
+ CH_DATE=$(date -u +"%Y-%m-%d %H:%M:%S")
262
+
263
+ # Prepare SQL INSERT query
264
+ SQL_QUERY="INSERT INTO docs_trademark_agreements.signatures (date, user_name, pr_number) VALUES ('$CH_DATE', '$USERNAME', $PR_NUMBER)"
265
+
266
+ echo "Executing SQL: $SQL_QUERY"
267
+
268
+ # Send to ClickHouse
269
+ RESPONSE=$(curl -s -w "%{http_code}" -o /tmp/ch_response.txt \
270
+ -X POST \
271
+ -H "x-clickhouse-user: docs_feedback" \
272
+ -H "x-clickhouse-key: " \
273
+ -H "Content-Type: text/plain" \
274
+ -d "$SQL_QUERY" \
275
+ "https://sql-clickhouse.clickhouse.com")
276
+
277
+ HTTP_CODE="${RESPONSE: -3}"
278
+ RESPONSE_BODY=$(cat /tmp/ch_response.txt)
279
+
280
+ if [ "$HTTP_CODE" = "200" ]; then
281
+ echo "✅ Signature stored successfully in ClickHouse"
309
282
else
310
- echo "ℹ️ No staged changes to commit"
283
+ echo "❌ Failed to store signature in ClickHouse"
284
+ echo "HTTP Code: $HTTP_CODE"
285
+ echo "Response: $RESPONSE_BODY"
286
+ # Don't exit 1 here - we don't want to fail the workflow if ClickHouse is down
287
+ echo "⚠️ Continuing workflow despite ClickHouse error"
311
288
fi
312
-
313
- - name : Create signature PR for forked contributions
314
- if : success() && steps.process-comment.outputs.is_fork == 'true' && steps.process-comment.outputs.pr_number != ''
315
- uses : actions/github-script@v7
316
- with :
317
- github-token : ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
318
- script : |
319
- const username = '${{ steps.process-comment.outputs.pr_author }}';
320
- const prNumber = '${{ steps.process-comment.outputs.pr_number }}';
321
- const signatureBranch = '${{ steps.record-signature.outputs.signature_branch }}';
322
-
323
- if (!signatureBranch) {
324
- console.log('No signature branch created, skipping PR creation');
325
- return;
326
- }
327
-
328
- // Create PR for the signature
329
- const { data: signaturePr } = await github.rest.pulls.create({
330
- owner: context.repo.owner,
331
- repo: context.repo.repo,
332
- title: `Add trademark signature for @${username} (PR #${prNumber})`,
333
- head: signatureBranch,
334
- base: 'main',
335
- body: [
336
- `## Trademark License Addendum Signature`,
337
- ``,
338
- `This PR automatically records the trademark license agreement signature for @${username} from PR #${prNumber}.`,
339
- ``,
340
- `**Details:**`,
341
- `- **Contributor:** @${username}`,
342
- `- **Original PR:** #${prNumber}`,
343
- `- **Date:** ${new Date().toISOString()}`,
344
- `- **Method:** Self-signed agreement via comment`,
345
- ``,
346
- `This signature was recorded automatically by the CLA approval workflow and should be merged to complete the signature recording process.`,
347
- ``,
348
- `Related to: #${prNumber}`
349
- ].join('\n')
350
- });
351
-
352
- console.log(`✅ Created signature PR #${signaturePr.number} for ${username}`);
0 commit comments