From afdbff0dea3059318c290260b3245301b4d05e9b Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Mon, 10 Oct 2022 13:01:14 -0400 Subject: [PATCH 1/8] Modify run.sh to use redirects rather than screen to create plan and log files. /cc #92 --- scripts/run.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f0a33b0..e4ee426 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -17,20 +17,12 @@ rm -f "$_logfile" rm -f "$_planfile" echo "INFO: _config_path: ${_config_path}" -if [ "${_doit}" = "--doit" ]; then - script "${_logfile}" -e -c \ - "octodns-sync --config-file=\"${_config_path}\" --doit \ - >>\"${_planfile}\"" -else - script "${_logfile}" -e -c \ - "octodns-sync --config-file=\"${_config_path}\" \ - >>\"${_planfile}\"" +if [ ! "${_doit}" = "--doit" ]; then + _doit= fi -# Exit 1 if octodns-sync exited non-zero. -if tail --lines=1 "$_logfile" | \ -grep --quiet --fixed-strings --invert-match \ -'[COMMAND_EXIT_CODE="0"]'; then +if ! octodns-sync --config-file="${_config_path}" "${_doit}" \ +1>"${_planfile}" 2>"${_logfile}"; then echo "FAIL: octodns-sync exited with an error." exit 1 fi From 6b70945c2e993b084ea1f82b4ec1b81ca1ba7527 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Mon, 17 Oct 2022 17:45:13 -0400 Subject: [PATCH 2/8] Mention the log output no longer appears in the workflow run log. --- scripts/run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/run.sh b/scripts/run.sh index e4ee426..f74e047 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -24,9 +24,15 @@ fi if ! octodns-sync --config-file="${_config_path}" "${_doit}" \ 1>"${_planfile}" 2>"${_logfile}"; then echo "FAIL: octodns-sync exited with an error." + echo "FAIL: Here are the contents of ${_logfile}:" + cat "${_logfile}" exit 1 fi +# Acknowledge that the log output went away; Link to issue +echo "INFO: octodns-sync log output has been written to ${_logfile}" +echo "INFO: https://github.com/solvaholic/octodns-sync/issues/92" + # https://github.community/t/set-output-truncates-multiline-strings/16852/4 _plan="$(cat "$_planfile")" _plan="${_plan//'%'/'%25'}" From 2dba326284cf7d0a382075fe286551ecdbbe52e9 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Mon, 17 Oct 2022 17:55:14 -0400 Subject: [PATCH 3/8] Add $_logfile as Action output "log" --- README.md | 8 ++++---- action.yml | 3 +++ scripts/run.sh | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c8cfa8..79fffbd 100644 --- a/README.md +++ b/README.md @@ -93,13 +93,13 @@ Default `"Not set"`. If you have configured `plan_outputs` for **octodns**, PlanHtml or PlanMarkdown output will be written to `$GITHUB_WORKSPACE/octodns-sync.plan`. -For convenience, this file is output by this action as the `plan` output if you need to use it in subsequent steps. +For convenience, this file is output by this action as the `plan` output so you may use it in subsequent steps. -### Log file +### log -`octodns-sync` will compare your configuration file to the configurations your providers have, and report any planned changes. The command logs this output in the workflow run log. +`octodns-sync` does not write its output to the workflow run log. Its output will be written to `$GITHUB_WORKSPACE/octodns-sync.log`. -That same output is saved to `$GITHUB_WORKSPACE/octodns-sync.log`. +For convenience, this file is output by this action as the `log` output so you may use it in subsequent steps. ### Add pull request comment diff --git a/action.yml b/action.yml index 819de32..b4ba3f8 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,9 @@ inputs: required: true default: 'Not set' outputs: + log: + description: '`octodns-sync` command output' + value: ${{ steps.run.outputs.log}} plan: description: 'Planned changes, if configured in octodns' value: ${{ steps.run.outputs.plan}} diff --git a/scripts/run.sh b/scripts/run.sh index f74e047..c42e005 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -34,10 +34,15 @@ echo "INFO: octodns-sync log output has been written to ${_logfile}" echo "INFO: https://github.com/solvaholic/octodns-sync/issues/92" # https://github.community/t/set-output-truncates-multiline-strings/16852/4 +_log="$(cat "$_logfile")" +_log="${_log//'%'/'%25'}" +_log="${_log//$'\n'/'%0A'}" +_log="${_log//$'\r'/'%0D'}" _plan="$(cat "$_planfile")" _plan="${_plan//'%'/'%25'}" _plan="${_plan//$'\n'/'%0A'}" _plan="${_plan//$'\r'/'%0D'}" -# Output the plan file +# Output the plan and log +echo "::set-output name=log::${_log}" echo "::set-output name=plan::${_plan}" From 3a271254bd0cd842a9a78a8f0dbf7c4924976568 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Mon, 17 Oct 2022 18:11:59 -0400 Subject: [PATCH 4/8] Update CHANGELOG.md --- docs/CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7ce1235..a0c23c0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- ([#93](https://github.com/solvaholic/octodns-sync/pull/93)) Add output **log** to include output from `octodns-sync` command. + +### Removed + +- ([#93](https://github.com/solvaholic/octodns-sync/pull/93)) `octodns-sync` command output no longer appears in workflow run logs. + +### Fixed + +- ([#92](https://github.com/solvaholic/octodns-sync/issues/92)) `octodns-sync` may silently fail on some Actions runners + ## [3.0.0] - 2022-06-21 ### Removed From 6a909e6f15ed161ff056f14b9c24a5d1148fdfc9 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 18 Oct 2022 15:53:21 -0400 Subject: [PATCH 5/8] Use environment rather than set-output in run.sh /cc #94 https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings --- scripts/run.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index c42e005..f9212ff 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -33,16 +33,10 @@ fi echo "INFO: octodns-sync log output has been written to ${_logfile}" echo "INFO: https://github.com/solvaholic/octodns-sync/issues/92" -# https://github.community/t/set-output-truncates-multiline-strings/16852/4 -_log="$(cat "$_logfile")" -_log="${_log//'%'/'%25'}" -_log="${_log//$'\n'/'%0A'}" -_log="${_log//$'\r'/'%0D'}" -_plan="$(cat "$_planfile")" -_plan="${_plan//'%'/'%25'}" -_plan="${_plan//$'\n'/'%0A'}" -_plan="${_plan//$'\r'/'%0D'}" - -# Output the plan and log -echo "::set-output name=log::${_log}" -echo "::set-output name=plan::${_plan}" +# Set the plan and log outputs +echo 'log<> $GITHUB_ENV +cat "$_logfile" >> $GITHUB_ENV +echo 'EOF' >> $GITHUB_ENV +echo 'plan<> $GITHUB_ENV +cat "$_planfile" >> $GITHUB_ENV +echo 'EOF' >> $GITHUB_ENV From 9b7573e1d162ef569ef50eee1573521211971bab Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 18 Oct 2022 21:20:55 -0400 Subject: [PATCH 6/8] echo the cat in run.sh kindof like what was done in https://github.com/rlespinasse/git-commit-data-action/pull/12 /cc #94 --- scripts/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index f9212ff..4d18057 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -35,8 +35,8 @@ echo "INFO: https://github.com/solvaholic/octodns-sync/issues/92" # Set the plan and log outputs echo 'log<> $GITHUB_ENV -cat "$_logfile" >> $GITHUB_ENV +echo "$(cat "$_logfile")" >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV echo 'plan<> $GITHUB_ENV -cat "$_planfile" >> $GITHUB_ENV +echo "$(cat "$_planfile")" >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV From 7a47ad1b96d9f3e6fc5fd1b0adb4eb01eafecdca Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 18 Oct 2022 21:39:38 -0400 Subject: [PATCH 7/8] Use $GITHUB_OUTPUT rather than $GITHUB_ENV, to set outputs. /cc #94 --- scripts/run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 4d18057..3ee913d 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -34,9 +34,9 @@ echo "INFO: octodns-sync log output has been written to ${_logfile}" echo "INFO: https://github.com/solvaholic/octodns-sync/issues/92" # Set the plan and log outputs -echo 'log<> $GITHUB_ENV -echo "$(cat "$_logfile")" >> $GITHUB_ENV -echo 'EOF' >> $GITHUB_ENV -echo 'plan<> $GITHUB_ENV -echo "$(cat "$_planfile")" >> $GITHUB_ENV -echo 'EOF' >> $GITHUB_ENV +echo 'log<> $GITHUB_OUTPUT +echo "$(cat "$_logfile")" >> $GITHUB_OUTPUT +echo 'EOF' >> $GITHUB_OUTPUT +echo 'plan<> $GITHUB_OUTPUT +echo "$(cat "$_planfile")" >> $GITHUB_OUTPUT +echo 'EOF' >> $GITHUB_OUTPUT From 0f3f924c960f97954cc3dedb03f589325aa5ee09 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Wed, 19 Oct 2022 21:58:50 -0400 Subject: [PATCH 8/8] Remove quotes around ${_doit} and tell shellcheck not to worry about it --- scripts/run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/run.sh b/scripts/run.sh index 3ee913d..ea91fbe 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -5,6 +5,8 @@ # - CONFIG_PATH # - DOIT +# shellcheck disable=SC2005,SC2086,SC2129 + _config_path=$CONFIG_PATH _doit=$DOIT @@ -21,7 +23,7 @@ if [ ! "${_doit}" = "--doit" ]; then _doit= fi -if ! octodns-sync --config-file="${_config_path}" "${_doit}" \ +if ! octodns-sync --config-file="${_config_path}" ${_doit} \ 1>"${_planfile}" 2>"${_logfile}"; then echo "FAIL: octodns-sync exited with an error." echo "FAIL: Here are the contents of ${_logfile}:"