name: Pull request

on:
  pull_request:
    branches: [ master ]

env:
  CACHE_BUNDLER: ~/.bundler

jobs:
  build:
    name: Build and running Unit Tests
    runs-on: ubuntu-latest

    timeout-minutes: 30
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v2

      - name: set up JDK 17
        uses: actions/setup-java@v1
        with:
          java-version: 17

      - name: Cache gradle
        uses: actions/cache@v1
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Run Unit Tests
        uses: maierj/fastlane-action@v1.4.0
        env:
          APP_BUILD_NUMBER: ${{ env.GITHUB_RUN_ID }}
          APP_VERSION_CODE: ${{ github.run_number }}
        with:
          lane: unit_test
          skip-tracking: false
          subdirectory: fastlane
          bundle-install-path: CACHE_BUNDLER

      - name: Upload Bundle
        uses: actions/upload-artifact@v2
        with:
          name: android_debug_apk_${{ github.run_number }}.zip
          path: app/build/outputs/apk/debug/app-debug.apk