From 4d6a84a8294d035747404d00b88a925fc2640e1e Mon Sep 17 00:00:00 2001 From: Hadi Alqattan Date: Mon, 19 Oct 2020 00:24:33 +0300 Subject: [PATCH] Allow black's Github action params overriding. (#1755) * Allow default params overriding. * Update: docs and action.yaml. * The second contirbution, add my name to authors.md * Correct docs `with.args` example. * Just to rerun the Travis jobs. * chmod 755 --- README.md | 1 + action.yml | 2 +- Dockerfile => action/Dockerfile | 4 +++- action/entrypoint.sh | 10 ++++++++++ docs/authors.md | 1 + docs/github_actions.md | 4 +++- 6 files changed, 19 insertions(+), 3 deletions(-) rename Dockerfile => action/Dockerfile (64%) create mode 100755 action/entrypoint.sh diff --git a/README.md b/README.md index 2ca76dd..7cd4d7f 100644 --- a/README.md +++ b/README.md @@ -574,6 +574,7 @@ Multiple contributions by: - [Gregory P. Smith](mailto:greg@krypto.org) - Gustavo Camargo - hauntsaninja +- [Hadi Alqattan](mailto:alqattanhadizaki@gmail.com) - [Heaford](mailto:dan@heaford.com) - [Hugo Barrera](mailto::hugo@barrera.io) - Hugo van Kemenade diff --git a/action.yml b/action.yml index 2ce1c0b..60bf369 100644 --- a/action.yml +++ b/action.yml @@ -6,4 +6,4 @@ branding: icon: "check-circle" runs: using: "docker" - image: "Dockerfile" + image: "action/Dockerfile" diff --git a/Dockerfile b/action/Dockerfile similarity index 64% rename from Dockerfile rename to action/Dockerfile index a03d23a..eb22099 100644 --- a/Dockerfile +++ b/action/Dockerfile @@ -5,4 +5,6 @@ ENV PYTHONUNBUFFERED 1 RUN pip install --upgrade --no-cache-dir black -ENTRYPOINT /usr/local/bin/black --check --diff . +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action/entrypoint.sh b/action/entrypoint.sh new file mode 100755 index 0000000..dc86fa1 --- /dev/null +++ b/action/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +if [ $# -eq 0 ]; then + # Default (if no args provided). + sh -c "black . --check --diff" +else + # Custom args. + sh -c "black $*" +fi diff --git a/docs/authors.md b/docs/authors.md index a5349b4..ebf64ea 100644 --- a/docs/authors.md +++ b/docs/authors.md @@ -69,6 +69,7 @@ Multiple contributions by: - [Gregory P. Smith](mailto:greg@krypto.org) - Gustavo Camargo - hauntsaninja +- [Hadi Alqattan](mailto:alqattanhadizaki@gmail.com) - [Heaford](mailto:dan@heaford.com) - [Hugo Barrera](mailto::hugo@barrera.io) - Hugo van Kemenade diff --git a/docs/github_actions.md b/docs/github_actions.md index 7ff8754..ac80c2f 100644 --- a/docs/github_actions.md +++ b/docs/github_actions.md @@ -15,5 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: psf/black@stable + - uses: psf/black@stable # the default is equivalent to `black . --diff --check`. + with: # (optional - override the default parameters). + args: ". --diff --check" ``` -- 2.39.5