Skip to content

Commit f2c46d4

Browse files
committed
ci: Fix EOF parsing -2
Signed-off-by: Chaitanya Tata <[email protected]>
1 parent c33fb2d commit f2c46d4

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

.github/workflows/module-monitor.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,9 @@ jobs:
261261
f.write('\n'.join(diff_content))
262262
263263
print(f"DEBUG: Successfully wrote diff_output.txt", file=sys.stderr)
264-
265-
print("diff_output<<MODULE_MONITOR_DELIMITER", file=sys.stdout)
266-
print('\n'.join(diff_content), file=sys.stdout)
267-
print("MODULE_MONITOR_DELIMITER", file=sys.stdout)
268264
269265
except Exception as e:
270-
print("diff_output<<MODULE_MONITOR_DELIMITER", file=sys.stdout)
271-
print(f"Error generating comparison: {e}", file=sys.stdout)
272-
print("MODULE_MONITOR_DELIMITER", file=sys.stdout)
266+
print(f"Error generating comparison: {e}", file=sys.stderr)
273267
print("DEBUG: Python script completed successfully", file=sys.stderr)
274268
PYTHON_SCRIPT_EOF
275269
@@ -281,14 +275,12 @@ jobs:
281275
282276
if [ -f diff_output.txt ]; then
283277
echo "DEBUG: diff_output.txt exists, size: $(wc -c < diff_output.txt)" >&2
284-
echo "diff_output<<MODULE_MONITOR_DELIMITER" >> $GITHUB_OUTPUT
285-
cat diff_output.txt >> $GITHUB_OUTPUT
286-
echo "MODULE_MONITOR_DELIMITER" >> $GITHUB_OUTPUT
278+
# Use base64 encoding to avoid delimiter conflicts
279+
DIFF_CONTENT=$(cat diff_output.txt | base64 -w 0)
280+
echo "diff_output_encoded=$DIFF_CONTENT" >> $GITHUB_OUTPUT
287281
else
288282
echo "DEBUG: diff_output.txt not found" >&2
289-
echo "diff_output<<MODULE_MONITOR_DELIMITER" >> $GITHUB_OUTPUT
290-
echo "No changes detected" >> $GITHUB_OUTPUT
291-
echo "MODULE_MONITOR_DELIMITER" >> $GITHUB_OUTPUT
283+
echo "diff_output_encoded=" >> $GITHUB_OUTPUT
292284
fi
293285
294286
@@ -298,10 +290,21 @@ jobs:
298290
with:
299291
github-token: ${{ secrets.GITHUB_TOKEN }}
300292
script: |
301-
console.log('DEBUG: diff_output length:', process.env.diff_output ? process.env.diff_output.length : 0);
293+
// Decode the base64 content
294+
let diffOutput = 'No changes detected';
295+
if (process.env.diff_output_encoded) {
296+
try {
297+
diffOutput = Buffer.from(process.env.diff_output_encoded, 'base64').toString('utf8');
298+
} catch (e) {
299+
console.log('Error decoding diff_output:', e.message);
300+
diffOutput = 'Error decoding output';
301+
}
302+
}
303+
304+
console.log('DEBUG: diff_output length:', diffOutput.length);
302305
303306
const commentBody = '## Module Monitor\n\nChanges detected in module.yml\n\n' +
304-
(process.env.diff_output || 'No changes detected') + '\n\n' +
307+
diffOutput + '\n\n' +
305308
'This comment was automatically generated.';
306309
307310
try {
@@ -344,7 +347,7 @@ jobs:
344347
console.log('Workflow completed successfully - PR detection and diff generation worked correctly.');
345348
}
346349
env:
347-
diff_output: ${{ steps.set-output.outputs.diff_output }}
350+
diff_output_encoded: ${{ steps.set-output.outputs.diff_output_encoded }}
348351

349352

350353

@@ -354,5 +357,9 @@ jobs:
354357
echo "" >> $GITHUB_STEP_SUMMARY
355358
echo "### Changes in zephyr/module.yml:" >> $GITHUB_STEP_SUMMARY
356359
echo '```diff' >> $GITHUB_STEP_SUMMARY
357-
echo "${{ steps.set-output.outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
360+
if [ -n "${{ steps.set-output.outputs.diff_output_encoded }}" ]; then
361+
echo "${{ steps.set-output.outputs.diff_output_encoded }}" | base64 -d >> $GITHUB_STEP_SUMMARY
362+
else
363+
echo "No changes detected" >> $GITHUB_STEP_SUMMARY
364+
fi
358365
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)