GitHub action to apply black formatting + reorder-python-imports
Largely derived from
- Create
$GIT_REPO_ROOT_DIR/.github/workflows
- Create
$GIT_REPO_ROOT_DIR/.github/workflows/main.yml
Fill above file file with:
name: "PythonFormatting"
on: [push, pull_request]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Run reorder-python-imports + black formatter
- name: Black Code Formatter
uses: tdeboissiere/python-format-action@master
You can then add a status in your README by adding:
![](https://github.com/ACCOUNT_NAME/REPO_NAME/workflows/PythonFormatting/badge.svg)
If the name of your workflow contains a space, e.g. Python Formatting
, use %20
:
![](https://github.com/ACCOUNT_NAME/REPO_NAME/workflows/Python%20Formatting/badge.svg)