Release gh action (#1909)

* Gets gh-action ready for marketplace release

* Updates documentation and removes redundant gh-action input argument

* Fixes gh-action bug

This commit fixes a bug which caused not all input arguments were forwarder to the black formatter.

* Update README.md

Co-authored-by: Cooper Lees <me@cooperlees.com>

Co-authored-by: Cooper Lees <me@cooperlees.com>
This commit is contained in:
Rick Staa 2021-01-08 20:47:03 +01:00 committed by GitHub
parent 966baaacbc
commit ba3648d984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View File

@ -411,8 +411,16 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- uses: psf/black@stable - uses: psf/black@stable
with:
black_args: ". --check"
``` ```
### Inputs
#### `black_args`
**optional**: Black input arguments. Defaults to `. --check --diff`.
## Ignoring unmodified files ## Ignoring unmodified files
_Black_ remembers files it has already formatted, unless the `--diff` flag is used or _Black_ remembers files it has already formatted, unless the `--diff` flag is used or

View File

@ -1,6 +1,11 @@
name: "Black" name: "Black"
description: "The uncompromising Python code formatter." description: "The uncompromising Python code formatter."
author: "Łukasz Langa and contributors to Black" author: "Łukasz Langa and contributors to Black"
inputs:
black_args:
description: "Black input arguments."
required: false
default: ""
branding: branding:
color: "black" color: "black"
icon: "check-circle" icon: "check-circle"

View File

@ -1,10 +1,17 @@
#!/bin/sh #!/bin/sh
set -e set -e
if [ $# -eq 0 ]; then # If no arguments are given use current working directory
# Default (if no args provided). black_args=(".")
sh -c "black . --check --diff" if [ "$#" -eq 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
black_args+=(${INPUT_BLACK_ARGS})
elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
black_args+=($* ${INPUT_BLACK_ARGS})
elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" == "" ]; then
black_args+=($*)
else else
# Custom args. # Default (if no args provided).
sh -c "black $*" black_args+=("--check" "--diff")
fi fi
sh -c "black . ${black_args[*]}"