Skip to content

Commit 4e63d69

Browse files
Merge pull request #210 from aligent/fix/DO-2060_strip_ansi_color_codes
DO-2060: strip ANSI colour codes from the CDK diff output
2 parents 76f0ae8 + 104dd48 commit 4e63d69

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎.github/workflows/aws-cdk.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ jobs:
451451
DIFF_CMD: ${{ inputs.diff-command }}
452452
EXTRA_ARGUMENTS: ${{ steps.expand-inputs.outputs.extra-arguments }}
453453
STACK_NAME: ${{ inputs.stack-name || vars.STACK_NAME }}
454+
# Ask CDK, Nx and other tools using chalk or picocolors not to emit colour
455+
FORCE_COLOR: "0"
456+
NO_COLOR: "1"
454457
run: |
455458
echo "📊 Analysing deployment changes..."
456459
@@ -459,6 +462,10 @@ jobs:
459462
$EXTRA_ARGUMENTS \
460463
--no-color 2>&1 || true)
461464
465+
# Strip any ANSI escape codes that still get through (e.g. from Nx targets that
466+
# set color: true), so the diff file and PR comment are plain text.
467+
diff_output=$(sed -E 's/\x1b\[[0-9;?]*[ -/]*[@-~]//g' <<< "$diff_output")
468+
462469
# Save diff to file for analysis
463470
echo "$diff_output" > deployment-diff.txt
464471

0 commit comments

Comments
 (0)