name: "ci"

on:
  push:
    branches: [develop]
  pull_request:
    branches: [develop, staging, main]

jobs:
  lint-commit:
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@v4.2.2"
      - uses: "wagoid/commitlint-github-action@v6.1.2"

  lint-editorconfig-checker:
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@v4.2.2"
      - uses: "editorconfig-checker/action-editorconfig-checker@main"
      - run: "editorconfig-checker"

  # test:
  #   permissions:
  #     checks: "write"
  #   runs-on: "ubuntu-latest"
  #   steps:
  #     - uses: "actions/checkout@v4.2.2"
  #       with:
  #         lfs: true

  #     - uses: "actions/cache@v4.2.0"
  #       with:
  #         path: "Library"
  #         key: "Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}"
  #         restore-keys: |
  #           "Library-"

  #     - uses: "game-ci/unity-test-runner@v4.3.1"
  #       env:
  #         UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
  #         UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
  #         UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
  #       with:
  #         githubToken: ${{ secrets.GITHUB_TOKEN }}

  build:
    runs-on: "ubuntu-latest"
    steps:
      - uses: "actions/checkout@v4.2.2"
        with:
          lfs: true

      - uses: "actions/cache@v4.2.0"
        with:
          path: "Library"
          key: "Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }}"
          restore-keys: |
            "Library-"

      - uses: "game-ci/unity-builder@v4.3.0"
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          targetPlatform: "StandaloneLinux64"

      # - uses: "actions/upload-artifact@v4.4.3"
      #   with:
      #     name: "Build"
      #     path: "build"
