name: autofix.ci

on:
  pull_request:
  push:
    branches: ["main"]

permissions:
  contents: read

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  autofix:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v6

      - name: Check for merge conflict markers
        run: |
          if git grep -nEI '<{7} |>{7} |^={7}$' -- ':(exclude)*.md' ':(exclude)*.mdx'; then
            echo "::error::Merge conflict markers found in tracked files"
            exit 1
          fi

      - name: Install pnpm
        uses: pnpm/action-setup@v6

      - name: Setup Node
        uses: actions/setup-node@v6
        with:
          node-version: "lts/*"
          cache: "pnpm"

      - name: Install Dependencies
        run: pnpm install --frozen-lockfile

      - name: Remove Unused Dependencies
        run: pnpm knip --fix

      - name: Lint and Format
        run: pnpm check

      - name: Autofix
        uses: autofix-ci/action@7a166d7532b277f34e16238930461bf77f9d7ed8
