Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple runs of the action in the same job #66

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 2 additions & 5 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
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}"