From 014f50ba630669e41d861d8274d1383a1e50791d Mon Sep 17 00:00:00 2001 From: Jacob Grossbard Date: Mon, 7 Feb 2022 17:20:59 -0800 Subject: [PATCH] Add action to automatically apply Black (#30) --- .github/workflows/format-pr.yml | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/format-pr.yml diff --git a/.github/workflows/format-pr.yml b/.github/workflows/format-pr.yml new file mode 100644 index 0000000..19bd77e --- /dev/null +++ b/.github/workflows/format-pr.yml @@ -0,0 +1,36 @@ +name: Format PR + +on: + pull_request: + branches: [ master ] + +jobs: + format: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Configure git + run: | + git config user.name "Github Actions Bot" + git config user.email "<>" + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install black + - name: Format with Black + run: | + black . + - name: Commit formatted code + run: | + git update-index --refresh + git add . + if ! git diff-index --quiet HEAD -- ; then + git commit -m "Format with Black" + git push + fi