name: fix code styling

on:
    push:
        branches:
            - main
            - "*.x"
    pull_request:

jobs:
    format:
        runs-on: ubuntu-latest
        permissions:
            contents: write

        steps:
            - name: Checkout code
              uses: actions/checkout@v4

            - name: Install pnpm
              uses: pnpm/action-setup@v4
              with:
                  version: 10

            - name: Install dependencies
              run: pnpm install

            - name: Format code
              run: pnpm run format

            - name: Commit linted files
              uses: stefanzweifel/git-auto-commit-action@v5
              with:
                  commit_message: "Fix code styling"
