diff --git a/README.md b/README.md index 93332b3..4041637 100644 --- a/README.md +++ b/README.md @@ -93,12 +93,18 @@ Default `"v0.9.12"`. ## Outputs +### plan + +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. + +### Log file + `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. That same output is saved to `$GITHUB_WORKSPACE/octodns-sync.log`. -If you have configured `plan_outputs` for **octodns**, PlanHtml or PlanMarkdown output will be written to `$GITHUB_WORKSPACE/octodns-sync.plan`. - ### Add pull request comment If you would like this action to add the `octodns-sync` plan to a pull request comment, configure `plan_outputs` in your **octodns** configuration, for example `public.yml`: diff --git a/action.yml b/action.yml index 41d670e..620a564 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: description: 'Provide a token to use, if you set add_pr_comment to Yes.' required: true default: 'Not set' +outputs: + plan: + description: 'Planned changes, if configured in octodns' + value: ${{ steps.run.outputs.plan}} runs: using: 'composite' diff --git a/scripts/install.sh b/scripts/install.sh index 62ead64..5fdc92e 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -3,11 +3,8 @@ # Exit early if octodns is already installed if command -v octodns-sync; then - # Hello reader! - # This works as a cheap, relatively safe way to respond to #57 - # If you'd like to improve it, please raise an issue or PR - echo "FAIL: It looks like octodns is already installed." - exit 1 + echo "INFO: It looks like octodns is already installed." + exit 0 fi # Set some variables diff --git a/scripts/run.sh b/scripts/run.sh index ba77ff6..7aa4aaa 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -8,6 +8,10 @@ _doit=$DOIT _logfile="${GITHUB_WORKSPACE}/octodns-sync.log" _planfile="${GITHUB_WORKSPACE}/octodns-sync.plan" +echo "INFO: Cleaning up plan and log files if they already exist" +rm -f "$_logfile" +rm -f "$_planfile" + echo "INFO: _config_path: ${_config_path}" if [ "${_doit}" = "--doit" ]; then script "${_logfile}" -e -c \ @@ -25,4 +29,13 @@ grep --quiet --fixed-strings --invert-match \ '[COMMAND_EXIT_CODE="0"]'; then echo "FAIL: octodns-sync exited with an error." exit 1 -fi \ No newline at end of file +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}"