diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..a3633df7e --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,35 @@ +name: Auto-format with Black + +on: + push: + branches: [ master, main ] + pull_request: + +jobs: + format: + if: github.actor != 'github-actions[bot]' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.head_ref }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Black + run: pip install black==25.12.0 + + - name: Run Black + run: black . --line-length 120 --exclude '.*_pb2.pyi?$' + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "style: auto-format with black" + branch: ${{ github.head_ref }} \ No newline at end of file