name: Build

on:
  push:
    branches: [ new ]
  pull_request:
    branches: [ new ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin'
          cache: gradle

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew

      - name: Build with Gradle
        run: ./gradlew assembleDebug

      - name: Upload APK
        uses: actions/upload-artifact@v3
        with:
          name: OpenBoard-debug
          path: app/build/outputs/apk/debug/*-debug*.apk

      - name: Archive reports for failed job
        uses: actions/upload-artifact@v3
        with:
          name: reports
          path: '*/build/reports'
        if: ${{ failure() }}
