Repository: psf/black
Pull request: Add `version` to github action (and rewrite the whole thing while at it)
Allows setting the exact black version use with the github action.
This is useful to be able to avoid needing to deal with black formatting changes introduced in new black versions in unrelated pull-requests.

Problem statement:
Allow picking a specific black version in the github action
Sometimes we want to stick with the formatting rules of a specific black version for a little while until we've concluded large PRs to avoid merge conflicts.
The Github action currently does not support picking a specific version of black though.

Suggested solution: Add a parameter for the github action to pick a specific black version.

Hints from issue discussion:
Sounds good, a PR would be welcome.

Commit message: Add black_version to github action

Patch to review:
diff --git a/CHANGES.md b/CHANGES.md
index 97a3be33c93..82903ef0a6b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -45,6 +45,8 @@
 - PR #2053: Python 2 support is now optional, install with
   `python3 -m pip install black[python2]` to maintain support.
 
+- allow choosing black version with github action (#1940)
+
 #### _Packaging_
 
 - Self-contained native _Black_ binaries are now provided for releases via GitHub
diff --git a/action.yml b/action.yml
index 59b16a9fb6c..4d2ec1ac42b 100644
--- a/action.yml
+++ b/action.yml
@@ -6,9 +6,20 @@ inputs:
     description: "Black input arguments."
     required: false
     default: ""
+  black_version:
+    description: 'Version of black to use. E.g "==20.8b1"'
+    required: false
+    default: ""
 branding:
   color: "black"
   icon: "check-circle"
 runs:
-  using: "docker"
-  image: "action/Dockerfile"
+  using: composite
+  steps:
+    - run: pip install --upgrade --no-cache-dir black${{inputs.black_version}}
+      shell: bash
+    - id: run-black
+      run:
+        ${{ github.action_path }}/action/entrypoint.sh ${{ inputs.configuration }} ${{
+        inputs.sortPaths }}
+      shell: bash
diff --git a/action/Dockerfile b/action/Dockerfile
deleted file mode 100644
index eb2209940db..00000000000
--- a/action/Dockerfile
+++ /dev/null
@@ -1,10 +0,0 @@
-FROM python:3
-
-ENV PYTHONDONTWRITEBYTECODE 1
-ENV PYTHONUNBUFFERED 1
-
-RUN pip install --upgrade --no-cache-dir black
-
-COPY entrypoint.sh /entrypoint.sh
-
-ENTRYPOINT ["/entrypoint.sh"]


Code review comments:
diff_hunk: @@ -6,9 +6,20 @@ inputs:
     description: "Black input arguments."
     required: false
     default: ""
+  black_version:
+    description: 'Version of black to use. E.g "==20.8b1"'
path: action.yml
text: @user1:
Python Version specifier (PEP440) - e.g. "==20.8b1"