name: Verify
on:
  workflow_call:
  workflow_dispatch:

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install dependencies
        uses: ./.github/actions/install-dependencies

      - name: Lint code
        run: bun format && bun lint:fix
      
      - uses: stefanzweifel/git-auto-commit-action@v4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          commit_message: 'chore: format'
          commit_user_name: 'github-actions[bot]'
          commit_user_email: 'github-actions[bot]@users.noreply.github.com'

  build:
    name: Build
    needs: lint
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install dependencies
        uses: ./.github/actions/install-dependencies

      - name: Build
        run: bun run build