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/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 diff --git a/scripts/run.sh b/scripts/run.sh index f0a33b0..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 @@ -17,29 +19,26 @@ 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." + echo "FAIL: Here are the contents of ${_logfile}:" + cat "${_logfile}" exit 1 fi -# https://github.community/t/set-output-truncates-multiline-strings/16852/4 -_plan="$(cat "$_planfile")" -_plan="${_plan//'%'/'%25'}" -_plan="${_plan//$'\n'/'%0A'}" -_plan="${_plan//$'\r'/'%0D'}" - -# Output the plan file -echo "::set-output name=plan::${_plan}" +# 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" + +# Set the plan and log outputs +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