name: Format Code # Ensures code follows consistent formatting style on every push and pull request # Prevents unformatted code from being merged and keeps the codebase tidy automatically on: pull_request: branches: [main, develop] push: branches: [main, develop] workflow_dispatch: permissions: contents: write pull-requests: write jobs: format: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.11' - run: | pip install black isort - name: Check formatting if: github.event_name == 'pull_request' run: | black --check semantica/ isort --check-only semantica/ - name: Format code if: github.event_name != 'pull_request' run: | black semantica/ isort semantica/ - name: Create PR if: github.event_name != 'pull_request' uses: peter-evans/create-pull-request@v5 with: commit-message: "Auto-format code" title: "Auto-format code" branch: format/auto-format delete-branch: true