Skip to content

Commit c085e7a

Browse files
CI: Continue iterating on output (#188)
* CI: Continue iterating on output * Add base64 encoding due to multi-line output * Add checks * wip: checks * wip: checks, remove always() * Change CPG * Update GTM * Change CPG again * Change output method
1 parent 563cdb4 commit c085e7a

File tree

3 files changed

+78
-22
lines changed

3 files changed

+78
-22
lines changed

.github/workflows/create-build.yml

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ jobs:
4949
5050
if [ -z "$CHANGED_DEMOS" ]; then
5151
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
5359
fi
5460
55-
echo "demos<<EOF" >> $GITHUB_OUTPUT
56-
echo "$CHANGED_DEMOS" >> $GITHUB_OUTPUT
57-
echo "EOF" >> $GITHUB_OUTPUT
58-
5961
- name: Install DDN CLI
6062
run: |
6163
curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v4/get.sh | bash
@@ -124,8 +126,11 @@ jobs:
124126

125127
- name: Build all changed demos
126128
id: build
129+
if: steps.demo-setup.outputs.no_changes != 'true'
127130
run: |
128131
BUILDS_JSON="[]"
132+
echo "Starting build process..."
133+
echo "Demos to build: ${{ steps.demo-setup.outputs.demos }}"
129134
130135
while IFS= read -r demo; do
131136
echo "Building demo: $demo"
@@ -261,25 +266,53 @@ jobs:
261266
esac
262267
263268
# Build this demo
269+
echo "Running ddn supergraph build create for $demo..."
264270
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"
265273
266274
# Add demo name to build output and append to array
267275
BUILD_WITH_DEMO=$(echo "$BUILD_OUTPUT" | jq ". + {\"demo\": \"$demo\"}")
276+
echo "Build with demo name added:"
277+
echo "$BUILD_WITH_DEMO"
278+
268279
BUILDS_JSON=$(echo "$BUILDS_JSON" | jq ". += [$BUILD_WITH_DEMO]")
280+
echo "Updated builds array:"
281+
echo "$BUILDS_JSON"
269282
270283
cd ../..
271284
done <<< "${{ steps.demo-setup.outputs.demos }}"
272285
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
276307
277308
- name: Comment on PR
278-
if: always()
309+
id: pr-comment
310+
if: steps.demo-setup.outputs.no_changes != 'true'
279311
uses: actions/github-script@v7
280312
with:
281313
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);
283316
const commitSha = context.payload.pull_request.head.sha.substring(0, 7);
284317
285318
let comment = `## 🚀 PromptQL Builds Complete (${commitSha})\n\n`;
@@ -295,23 +328,38 @@ jobs:
295328
comment += `\n`;
296329
});
297330
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({
300333
issue_number: context.issue.number,
301334
owner: context.repo.owner,
302335
repo: context.repo.repo,
303336
body: comment
304337
});
305338
339+
return response.data.id;
340+
306341
- name: Notify Slack
307-
if: always()
342+
if: steps.demo-setup.outputs.no_changes != 'true'
308343
uses: actions/github-script@v7
309344
env:
310345
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
311346
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
312347
with:
313348
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);
315363
const commitSha = context.payload.pull_request.head.sha.substring(0, 7);
316364
317365
// Create message for each build
@@ -328,7 +376,7 @@ jobs:
328376
slackMessage += `\n`;
329377
});
330378
331-
// Find existing PR thread
379+
// Find existing PR thread by looking for build comments
332380
const comments = await github.rest.issues.listComments({
333381
issue_number: context.issue.number,
334382
owner: context.repo.owner,
@@ -337,11 +385,12 @@ jobs:
337385
338386
let threadTs = null;
339387
const threadComment = comments.data.find(comment =>
388+
comment.body.includes('🚀 PromptQL Builds Complete') &&
340389
comment.body.includes('<!-- slack-thread-ts:')
341390
);
342391
343392
if (threadComment) {
344-
const match = threadComment.body.match(/<!-- slack-thread-ts:([^-]+) -->/);
393+
const match = threadComment.body.match(/<!-- slack-thread-ts:([^-\s]+)/);
345394
threadTs = match ? match[1] : null;
346395
}
347396
@@ -369,12 +418,19 @@ jobs:
369418
if (slackData.ok) {
370419
threadTs = slackData.ts;
371420
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({
375430
owner: context.repo.owner,
376431
repo: context.repo.repo,
377-
body: `<!-- slack-thread-ts:${threadTs} -->`
432+
comment_id: commentId,
433+
body: existingComment.data.body + `\n<!-- slack-thread-ts:${threadTs} -->`
378434
});
379435
}
380436
}

demos/cpg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# CPG Demo
22

3-
Adding here as a test to trigger CI.
3+
Adding here as a test to trigger CI...

demos/gtm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# GTM Demo
22

3-
Adding here as a test to trigger CI.
3+
Adding here as a test to trigger CI...

0 commit comments

Comments
 (0)