Skip to content

testing

testing #9

name: Check Python Code Formatting
on:
pull_request:
branches:
- main
jobs:
format-check:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12.x"
- name: Install Black
run: pip install black
- name: Run Black
run: black .
- name: Commit changes if formatting is needed
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --cached --exit-code || git commit -m "Auto-format code with Black"
- name: Push changes back to the pull request branch
uses: peter-evans/create-pull-request@v7
with:
base: ${{github.head_ref}}
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: main
title: Formatting Code
body: Formatting code with black