@@ -49,13 +49,15 @@ jobs:
49
49
50
50
if [ -z "$CHANGED_DEMOS" ]; then
51
51
echo "No demo changes detected"
52
- exit 1
52
+ echo "demos=" >> $GITHUB_OUTPUT
53
+ echo "no_changes=true" >> $GITHUB_OUTPUT
54
+ else
55
+ echo "demos<<EOF" >> $GITHUB_OUTPUT
56
+ echo "$CHANGED_DEMOS" >> $GITHUB_OUTPUT
57
+ echo "EOF" >> $GITHUB_OUTPUT
58
+ echo "no_changes=false" >> $GITHUB_OUTPUT
53
59
fi
54
60
55
- echo "demos<<EOF" >> $GITHUB_OUTPUT
56
- echo "$CHANGED_DEMOS" >> $GITHUB_OUTPUT
57
- echo "EOF" >> $GITHUB_OUTPUT
58
-
59
61
- name : Install DDN CLI
60
62
run : |
61
63
curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v4/get.sh | bash
@@ -124,8 +126,11 @@ jobs:
124
126
125
127
- name : Build all changed demos
126
128
id : build
129
+ if : steps.demo-setup.outputs.no_changes != 'true'
127
130
run : |
128
131
BUILDS_JSON="[]"
132
+ echo "Starting build process..."
133
+ echo "Demos to build: ${{ steps.demo-setup.outputs.demos }}"
129
134
130
135
while IFS= read -r demo; do
131
136
echo "Building demo: $demo"
@@ -261,25 +266,53 @@ jobs:
261
266
esac
262
267
263
268
# Build this demo
269
+ echo "Running ddn supergraph build create for $demo..."
264
270
BUILD_OUTPUT=$(ddn supergraph build create --out json -d "PR #${{ github.event.number }}: ${{ github.event.pull_request.title }} ($demo)")
271
+ echo "Raw build output for $demo:"
272
+ echo "$BUILD_OUTPUT"
265
273
266
274
# Add demo name to build output and append to array
267
275
BUILD_WITH_DEMO=$(echo "$BUILD_OUTPUT" | jq ". + {\"demo\": \"$demo\"}")
276
+ echo "Build with demo name added:"
277
+ echo "$BUILD_WITH_DEMO"
278
+
268
279
BUILDS_JSON=$(echo "$BUILDS_JSON" | jq ". += [$BUILD_WITH_DEMO]")
280
+ echo "Updated builds array:"
281
+ echo "$BUILDS_JSON"
269
282
270
283
cd ../..
271
284
done <<< "${{ steps.demo-setup.outputs.demos }}"
272
285
273
- echo "builds_output<<EOF" >> $GITHUB_OUTPUT
274
- echo "$BUILDS_JSON" >> $GITHUB_OUTPUT
275
- echo "EOF" >> $GITHUB_OUTPUT
286
+ echo "Final builds output:"
287
+ echo "$BUILDS_JSON"
288
+
289
+ # Use base64 encoding to preserve the JSON structure
290
+ echo "builds_output=$(echo "$BUILDS_JSON" | base64 -w 0)" >> $GITHUB_OUTPUT
291
+
292
+ - name : Debug build output
293
+ if : always() && steps.demo-setup.outputs.no_changes != 'true'
294
+ run : |
295
+ echo "Build step outputs:"
296
+ BUILDS_OUTPUT=$(echo "${{ steps.build.outputs.builds_output }}" | base64 -d)
297
+ echo "builds_output = $BUILDS_OUTPUT"
298
+ echo "Length of builds_output: ${#BUILDS_OUTPUT}"
299
+
300
+ # Try to parse it as JSON
301
+ if echo "$BUILDS_OUTPUT" | jq . > /dev/null 2>&1; then
302
+ echo "✅ builds_output is valid JSON"
303
+ echo "$BUILDS_OUTPUT" | jq .
304
+ else
305
+ echo "❌ builds_output is not valid JSON"
306
+ fi
276
307
277
308
- name : Comment on PR
278
- if : always()
309
+ id : pr-comment
310
+ if : steps.demo-setup.outputs.no_changes != 'true'
279
311
uses : actions/github-script@v7
280
312
with :
281
313
script : |
282
- const builds = JSON.parse(`${{ steps.build.outputs.builds_output }}`);
314
+ const buildsJson = Buffer.from('${{ steps.build.outputs.builds_output }}', 'base64').toString();
315
+ const builds = JSON.parse(buildsJson);
283
316
const commitSha = context.payload.pull_request.head.sha.substring(0, 7);
284
317
285
318
let comment = `## 🚀 PromptQL Builds Complete (${commitSha})\n\n`;
@@ -295,23 +328,38 @@ jobs:
295
328
comment += `\n`;
296
329
});
297
330
298
- // Always create a new comment
299
- await github.rest.issues.createComment({
331
+ // Create the comment and return its ID
332
+ const response = await github.rest.issues.createComment({
300
333
issue_number: context.issue.number,
301
334
owner: context.repo.owner,
302
335
repo: context.repo.repo,
303
336
body: comment
304
337
});
305
338
339
+ return response.data.id;
340
+
306
341
- name : Notify Slack
307
- if : always()
342
+ if : steps.demo-setup.outputs.no_changes != 'true'
308
343
uses : actions/github-script@v7
309
344
env :
310
345
SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
311
346
SLACK_CHANNEL_ID : ${{ secrets.SLACK_CHANNEL_ID }}
312
347
with :
313
348
script : |
314
- const builds = JSON.parse(`${{ steps.build.outputs.builds_output }}`);
349
+ // Debug: Check if secrets are available
350
+ if (!process.env.SLACK_BOT_TOKEN) {
351
+ console.log('❌ SLACK_BOT_TOKEN secret not found');
352
+ return;
353
+ }
354
+ if (!process.env.SLACK_CHANNEL_ID) {
355
+ console.log('❌ SLACK_CHANNEL_ID secret not found');
356
+ return;
357
+ }
358
+
359
+ console.log('✅ Slack secrets found');
360
+
361
+ const buildsJson = Buffer.from('${{ steps.build.outputs.builds_output }}', 'base64').toString();
362
+ const builds = JSON.parse(buildsJson);
315
363
const commitSha = context.payload.pull_request.head.sha.substring(0, 7);
316
364
317
365
// Create message for each build
@@ -328,7 +376,7 @@ jobs:
328
376
slackMessage += `\n`;
329
377
});
330
378
331
- // Find existing PR thread
379
+ // Find existing PR thread by looking for build comments
332
380
const comments = await github.rest.issues.listComments({
333
381
issue_number: context.issue.number,
334
382
owner: context.repo.owner,
@@ -337,11 +385,12 @@ jobs:
337
385
338
386
let threadTs = null;
339
387
const threadComment = comments.data.find(comment =>
388
+ comment.body.includes('🚀 PromptQL Builds Complete') &&
340
389
comment.body.includes('<!-- slack-thread-ts:')
341
390
);
342
391
343
392
if (threadComment) {
344
- const match = threadComment.body.match(/<!-- slack-thread-ts:([^-]+) --> /);
393
+ const match = threadComment.body.match(/<!-- slack-thread-ts:([^-\s ]+)/);
345
394
threadTs = match ? match[1] : null;
346
395
}
347
396
@@ -369,12 +418,19 @@ jobs:
369
418
if (slackData.ok) {
370
419
threadTs = slackData.ts;
371
420
372
- // Store thread timestamp
373
- await github.rest.issues.createComment({
374
- issue_number: context.issue.number,
421
+ // Update the GitHub comment with thread timestamp
422
+ const commentId = ${{ steps.pr-comment.outputs.result }};
423
+ const existingComment = await github.rest.issues.getComment({
424
+ owner: context.repo.owner,
425
+ repo: context.repo.repo,
426
+ comment_id: commentId
427
+ });
428
+
429
+ await github.rest.issues.updateComment({
375
430
owner: context.repo.owner,
376
431
repo: context.repo.repo,
377
- body: `<!-- slack-thread-ts:${threadTs} -->`
432
+ comment_id: commentId,
433
+ body: existingComment.data.body + `\n<!-- slack-thread-ts:${threadTs} -->`
378
434
});
379
435
}
380
436
}
0 commit comments