Skip to content

Commit

Permalink
Allow specification of dry_run and debug in CI
Browse files Browse the repository at this point in the history
You can now easily set the action to debug and dry_run mode in the CI by
specifying the relevant inputs.
  • Loading branch information
SebastiaanZ committed Dec 9, 2020
1 parent 8517fa6 commit ac398ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ jobs:
| pr_title | Title of the Pull Request | no¹ |
| pr_source | Source branch for the Pull Request | no¹ |
| pull_request_payload | PR payload in JSON format² | no³ |
| debug | set to "true" to turn on debug logging | no |
| dry_run | set to "true" to not send the webhook request | no |

1) The Action will determine whether to send an embed tailored towards a Pull Request Check Run or towards a general workflow run based on the presence of non-null values for the four pull request arguments. This means that you either have to provide **all** of them or **none** of them.

Expand Down
13 changes: 13 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ inputs:
description: 'Pull Request in jSON payload form'
required: false

debug:
description: 'Pull Request in jSON payload form'
required: false
default: 'false'

dry_run:
description: 'Pull Request in jSON payload form'
required: false
default: 'false'

runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -82,6 +92,9 @@ runs:
- ${{ inputs.pr_number }}
- ${{ inputs.pr_title }}
- ${{ inputs.pr_source }}
- ${{ inputs.pull_request_payload }}
- ${{ inputs.debug }}
- ${{ inputs.dry_run }}

branding:
icon: 'check-circle'
Expand Down
17 changes: 2 additions & 15 deletions github_status_embed/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,11 @@
for argument, configuration in action_specs["inputs"].items():
parser.add_argument(argument, help=configuration["description"])

parser.add_argument(
"--debug",
help="enable debug logging",
action="store_true",
dest="debug",
)
parser.add_argument(
"--dry-run",
help="do not send webhook request",
action="store_true",
dest="dry_run"
)


if __name__ == "__main__":
arguments = vars(parser.parse_args())
debug = arguments.pop('debug')
dry_run = arguments.pop('dry_run')
debug = arguments.pop('debug') not in ('', '0', 'false')
dry_run = arguments.pop('dry_run') not in ('', '0', 'false')

# Set up logging and make sure to mask the webhook_token in log records
level = logging.DEBUG if debug else logging.WARNING
Expand Down

0 comments on commit ac398ce

Please sign in to comment.