Skip to content

Add pre-commit configuration to apply Black formatting #12

Add pre-commit configuration to apply Black formatting

Add pre-commit configuration to apply Black formatting #12

Workflow file for this run

name: Autoformat
on: [pull_request]
permissions:
contents: write
jobs:
black:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Init environment
uses: ./.github/actions/init-environment
- name: Run formatter
run: black .
- name: Commit any changes
env:
GITHUB_TOKEN: ${{ secrets.GRIPTAPE_AUTOFORMATTER_TOKEN }}
run: |
if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
git config user.name griptape-autoformatter
git config user.password ${GITHUB_TOKEN}
git commit -am "Autoformat with Black"
git push
fi