name: autofix.ci # needed to securely identify the workflow

on:
  pull_request:
    branches-ignore:
      - 'renovate/**'
permissions:
  contents: read

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  autofix:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

      - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
        # uses version from "packageManager" field in package.json

      - name: Setup Node.js
        uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
        with:
          cache: pnpm
          node-version-file: '.node-version'

      - name: Install Packages
        run: |
          pnpm install --frozen-lockfile
        env:
          CYPRESS_CACHE_FOLDER: .cache/Cypress

      - name: Fix Linting
        shell: bash
        run: pnpm -w run lint:fix

      - name: Sync `./src/config.type.ts` with `./src/schemas/config.schema.yaml`
        shell: bash
        run: pnpm run --filter mermaid types:build-config

      - name: Build Docs
        working-directory: ./packages/mermaid
        run: pnpm run docs:build

      - uses: autofix-ci/action@551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef # main
