From 5e78c1aef21a6767277783180988ef26be7626a0 Mon Sep 17 00:00:00 2001 From: Jeremy Adams Date: Wed, 30 Oct 2024 11:07:33 -0700 Subject: [PATCH 1/4] feat: add step summary in code block Signed-off-by: Jeremy Adams --- action.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/action.yml b/action.yml index c11a7c3..31d316d 100644 --- a/action.yml +++ b/action.yml @@ -75,6 +75,8 @@ runs: INPUT_MODULE: ${{ inputs.module }} run: | tmpout=$(mktemp) + # Run the command and capture its output in `tmpout` + # while also displaying it in the logs cd ${{ inputs.workdir }} && { \ DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ dagger \ @@ -83,8 +85,19 @@ runs: ${INPUT_MODULE:+-m $INPUT_MODULE} \ ${{ inputs.args }}; } | tee "${tmpout}" + # Send the output to GITHUB_OUTPUT for further processing if needed (echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT" + # Append formatted output to GITHUB_STEP_SUMMARY + { + echo "### Dagger Output" + echo "" + echo "
"
+          cat "${tmpout}"
+          echo "
" + echo "" + } >> $GITHUB_STEP_SUMMARY + - if: inputs.engine-stop == 'true' shell: bash run: | From 853159db1f6b147ef2b25905f17fab87022e78ea Mon Sep 17 00:00:00 2001 From: Jeremy Adams Date: Wed, 30 Oct 2024 21:22:44 -0700 Subject: [PATCH 2/4] stderr Signed-off-by: Jeremy Adams --- action.yml | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index 31d316d..40c3931 100644 --- a/action.yml +++ b/action.yml @@ -75,22 +75,24 @@ runs: INPUT_MODULE: ${{ inputs.module }} run: | tmpout=$(mktemp) - # Run the command and capture its output in `tmpout` - # while also displaying it in the logs - cd ${{ inputs.workdir }} && { \ - DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ - dagger \ - ${{ inputs.dagger-flags }} \ - ${{ inputs.verb }} \ - ${INPUT_MODULE:+-m $INPUT_MODULE} \ - ${{ inputs.args }}; } | tee "${tmpout}" - - # Send the output to GITHUB_OUTPUT for further processing if needed + tmperr=$(mktemp) + + # Run the command and capture stdout and stderr separately + cd ${{ inputs.workdir }} && { + DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ + dagger \ + ${{ inputs.dagger-flags }} \ + ${{ inputs.verb }} \ + ${INPUT_MODULE:+-m $INPUT_MODULE} \ + ${{ inputs.args }} + } >"${tmpout}" 2>"${tmperr}" # Redirect stdout to tmpout and stderr to tmperr + + # Send stdout to GITHUB_OUTPUT (echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT" - - # Append formatted output to GITHUB_STEP_SUMMARY + + # Append formatted stdout to GITHUB_STEP_SUMMARY { - echo "### Dagger Output" + echo "### Dagger stdout" echo "" echo "
"
           cat "${tmpout}"
@@ -98,6 +100,16 @@ runs:
           echo ""
         } >> $GITHUB_STEP_SUMMARY
 
+        # Append formatted stderr to GITHUB_STEP_SUMMARY
+        {
+          echo "### Dagger stderr"
+          echo ""
+          echo "
"
+          cat "${tmperr}"
+          echo "
" + echo "" + } >> $GITHUB_STEP_SUMMARY + - if: inputs.engine-stop == 'true' shell: bash run: | From b8e91e035e6eed43539bcd4002193faede994ebf Mon Sep 17 00:00:00 2001 From: Jeremy Adams Date: Wed, 30 Oct 2024 21:33:23 -0700 Subject: [PATCH 3/4] ansi-2-html Signed-off-by: Jeremy Adams --- action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 40c3931..3de3a77 100644 --- a/action.yml +++ b/action.yml @@ -90,11 +90,14 @@ runs: # Send stdout to GITHUB_OUTPUT (echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT" + # Set up ANSI to HTML converter + sudo npm install -g ansi-to-html + # Append formatted stdout to GITHUB_STEP_SUMMARY { echo "### Dagger stdout" echo "" - echo "
"
+          echo -n "
"
           cat "${tmpout}"
           echo "
" echo "" @@ -104,8 +107,8 @@ runs: { echo "### Dagger stderr" echo "" - echo "
"
-          cat "${tmperr}"
+          echo -n "
"
+          ansi-to-html < "${tmperr}"
           echo "
" echo "" } >> $GITHUB_STEP_SUMMARY From 9c86de824d752deef667ae243e6494a5c84fec40 Mon Sep 17 00:00:00 2001 From: Jeremy Adams Date: Thu, 31 Oct 2024 23:10:01 -0700 Subject: [PATCH 4/4] tee both stdout and stderr Signed-off-by: Jeremy Adams --- action.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 3de3a77..002e011 100644 --- a/action.yml +++ b/action.yml @@ -77,16 +77,15 @@ runs: tmpout=$(mktemp) tmperr=$(mktemp) - # Run the command and capture stdout and stderr separately cd ${{ inputs.workdir }} && { - DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ - dagger \ - ${{ inputs.dagger-flags }} \ - ${{ inputs.verb }} \ - ${INPUT_MODULE:+-m $INPUT_MODULE} \ - ${{ inputs.args }} - } >"${tmpout}" 2>"${tmperr}" # Redirect stdout to tmpout and stderr to tmperr - + DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \ + dagger \ + ${{ inputs.dagger-flags }} \ + ${{ inputs.verb }} \ + ${INPUT_MODULE:+-m $INPUT_MODULE} \ + ${{ inputs.args }} + } > >(tee "${tmpout}") 2> >(tee "${tmperr}" >&2) + # Send stdout to GITHUB_OUTPUT (echo -n "stdout=" && cat "${tmpout}") >> "$GITHUB_OUTPUT"