name: Tests

on: [push, workflow_dispatch]

jobs:
  runPush:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Trigger BE build
      if: ${{ github.repository == 'Anuken/Mindustry' }}
      run: |
        git clone --depth=1 --branch=master https://github.com/Anuken/MindustryBuilds ../MindustryBuilds
        cd ../MindustryBuilds
        BNUM=$(($GITHUB_RUN_NUMBER + 20000))
        git tag ${BNUM}
        git config --global user.name "Build Uploader"
        git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryBuilds ${BNUM}
    - name: Set up JDK 17
      uses: actions/setup-java@v1
      with:
        java-version: 17
    - name: Run unit tests
      run: ./gradlew clean cleanTest test --stacktrace
