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

Release gh action #1909

Merged
merged 4 commits into from
Jan 8, 2021
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,16 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: psf/black@stable
with:
black_args: ". --check"
```

### Inputs
rickstaa marked this conversation as resolved.
Show resolved Hide resolved

#### `black_args`

**optional**: Black input arguments. Defaults to `. --check --diff`.

## Ignoring unmodified files

_Black_ remembers files it has already formatted, unless the `--diff` flag is used or
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Black"
description: "The uncompromising Python code formatter."
author: "Łukasz Langa and contributors to Black"
inputs:
black_args:
description: "Black input arguments."
required: false
default: ""
branding:
color: "black"
icon: "check-circle"
Expand Down
17 changes: 12 additions & 5 deletions action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/sh
set -e

if [ $# -eq 0 ]; then
# Default (if no args provided).
sh -c "black . --check --diff"
# If no arguments are given use current working directory
black_args=(".")
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
# Custom args.
sh -c "black $*"
# Default (if no args provided).
black_args+=("--check" "--diff")
fi

sh -c "black . ${black_args[*]}"