mirror of
https://github.com/koenrh/dnscontrol-action.git
synced 2025-01-01 12:52:25 +08:00
Merge pull request #57 from koenrh/filter-preview-output
Reduce preview PR comment size
This commit is contained in:
commit
7d2c2d7629
4 changed files with 29 additions and 8 deletions
|
@ -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"]
|
||||
|
|
|
@ -105,7 +105,7 @@ GitHub Action.
|
|||
with:
|
||||
msg: |
|
||||
```
|
||||
${{ steps.dnscontrol_preview.outputs.output }}
|
||||
${{ steps.dnscontrol_preview.outputs.preview_comment }}
|
||||
```
|
||||
check_for_duplicate_msg: true
|
||||
```
|
||||
|
|
9
bin/filter-preview-output.sh
Executable file
9
bin/filter-preview-output.sh
Executable file
|
@ -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:'
|
|
@ -2,6 +2,17 @@
|
|||
|
||||
set -o pipefail
|
||||
|
||||
escape() {
|
||||
local input="$1"
|
||||
|
||||
# https://github.community/t/set-output-truncates-multiline-strings/16852/3
|
||||
input="${input//'%'/'%25'}"
|
||||
input="${input//$'\n'/'%0A'}"
|
||||
input="${input//$'\r'/'%0D'}"
|
||||
|
||||
echo "$input"
|
||||
}
|
||||
|
||||
# Resolve to full paths
|
||||
CONFIG_ABS_PATH="$(readlink -f "${INPUT_CONFIG_FILE}")"
|
||||
CREDS_ABS_PATH="$(readlink -f "${INPUT_CREDS_FILE}")"
|
||||
|
@ -25,10 +36,13 @@ EXIT_CODE="$?"
|
|||
|
||||
echo "$OUTPUT"
|
||||
|
||||
# https://github.community/t/set-output-truncates-multiline-strings/16852/3
|
||||
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)"
|
||||
|
||||
OUTPUT="$(escape "$OUTPUT")"
|
||||
FILTERED_OUTPUT="$(escape "$FILTERED_OUTPUT")"
|
||||
|
||||
echo "::set-output name=output::$OUTPUT"
|
||||
echo "::set-output name=preview_comment::$FILTERED_OUTPUT"
|
||||
|
||||
exit $EXIT_CODE
|
||||
|
|
Loading…
Reference in a new issue