From aedf90a0a5d66274e47c07e4bd407d3937e2fba1 Mon Sep 17 00:00:00 2001 From: Koen Rouwhorst Date: Tue, 13 Jul 2021 18:21:01 +0200 Subject: [PATCH] Reduce preview PR comment size --- Dockerfile | 4 +--- README.md | 2 +- bin/filter-preview-output.sh | 9 +++++++++ entrypoint.sh | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100755 bin/filter-preview-output.sh diff --git a/Dockerfile b/Dockerfile index da56af8..49ab65a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,5 @@ LABEL "com.github.actions.color"="yellow" RUN apk add --no-cache bash -COPY README.md / - -COPY entrypoint.sh /entrypoint.sh +COPY README.md entrypoint.sh bin/filter-preview-output.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 9359fa3..4163290 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ GitHub Action. with: msg: | ``` - ${{ steps.dnscontrol_preview.outputs.output }} + ${{ steps.dnscontrol_preview.outputs.preview_comment }} ``` check_for_duplicate_msg: true ``` diff --git a/bin/filter-preview-output.sh b/bin/filter-preview-output.sh new file mode 100755 index 0000000..d7aa360 --- /dev/null +++ b/bin/filter-preview-output.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# source: https://git.io/J86QD +grep -v -e '^\.\.\.0 corrections$' |\ + grep -v -e '^0 corrections' |\ + grep -v -e '\.\.\. (skipping)' |\ + grep -v -e '^----- DNS Provider: ' |\ + grep -v -e '^----- Registrar: ' |\ + grep -v -e '^----- Getting nameservers from:' diff --git a/entrypoint.sh b/entrypoint.sh index f79062d..730c272 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,5 +30,10 @@ OUTPUT="${OUTPUT//'%'/'%25'}" OUTPUT="${OUTPUT//$'\n'/'%0A'}" OUTPUT="${OUTPUT//$'\r'/'%0D'}" +# Filter output to reduce 'preview' PR comment length +FILTERED_OUTPUT="$(echo "$OUTPUT" | /filter-preview-output.sh)" + echo "::set-output name=output::$OUTPUT" +echo "::set-output name=preview_comment::$FILTERED_OUTPUT" + exit $EXIT_CODE