name: Prek

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - main

jobs:
  prek:
    # Do not run on release-plz PRs
    if: github.head_ref == '' || !startsWith(github.head_ref, 'release-plz-')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

      - name: Setup Lux
        uses: lumen-oss/gh-actions-lux@d12a6bdf3a380de5b9d142272e6fd95d28b44b8d # v1
        with:
          version: ${{ vars.LUX_VERSION }}

      - name: Sync project
        run: lx --lua-version ${{ vars.LUA_VERSION }} sync

      - name: Run prek
        uses: j178/prek-action@cbc2f23eb5539cf20d82d1aabd0d0ecbcc56f4e3 # v2
