Skip to content

Commit

Permalink
Merge pull request #93 from solvaholic/issue92
Browse files Browse the repository at this point in the history
Modify run.sh to use redirects rather than screen
  • Loading branch information
solvaholic authored Oct 25, 2022
2 parents 3953b5e + 0f3f924 commit 7404fec
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
14 changes: 14 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 19 additions & 20 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# - CONFIG_PATH
# - DOIT

# shellcheck disable=SC2005,SC2086,SC2129

_config_path=$CONFIG_PATH
_doit=$DOIT

Expand All @@ -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<<EOF' >> $GITHUB_OUTPUT
echo "$(cat "$_logfile")" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo 'plan<<EOF' >> $GITHUB_OUTPUT
echo "$(cat "$_planfile")" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

0 comments on commit 7404fec

Please sign in to comment.